2017-04-17 11 views
0

私は試してURL:http://127.0.0.1:8000/manifest/archive/?page=1。 正規表現パターン:(django)URLの正規表現が一致しません

  1. (私が試したオリジナル1):r'^archive/(?P<reverse>[n]{0,1})/?\?page=[0-9]+/?'
  2. (簡単に私もPythonのコンソールで試してみました。)r'^archive/\?page=[0-9]+'
  3. (最も簡単な可能、ちょうど試してくださいする。)r'^archive/\?page=1' (しかし私は正しい方法で疑問符を逃しましたか?)

私はこれらの正規表現をすべてPythonコンソールで試してみましたが、うまくいきました。問題は間違っていないと思います正規表現。

So:どうしてこれは機能しませんか?


オプション情報:

プロジェクトのURL-confの:

urlpatterns = [ 
    url(r'^admin/', admin.site.urls), 
    url(r'^$', RedirectView.as_view(url=reverse_lazy('manifest:index'))), 
    url(r'^manifest/', include('manifest.urls', namespace='manifest')), 
] 

注:URL 127.0.0.1:8000/manifest/indexマッチそれが必要なので、すべてが間違って行われる程度にはできませんように。


URLトレースバック:

Page not found (404)

Request Method: GET

Request URL: http://127.0.0.1:8000/manifest/archive/?page=1

Using the URLconf defined in asqiir005.urls, Django tried these URL patterns, in this order:

^admin/ 
^$ 
^manifest/ ^$ [name='index'] 
^manifest/ ^(?P<number>[0-9]+)$ [name='article'] 
^manifest/ ^archive/\?page=1 
^manifest/ ^archive/(?P<reverse>[n]{0,1})/?\?page=[0-9]+/? [name='paged_archive'] 
^manifest/ ^archive/all/(?P<reverse>[n]{0,1})/?$ [name='whole_archive'] 
^media\/(?P<path>.*)$ 

The current URL, manifest/archive/, didn't match any of these.

+0

私たちは本当にURLのクエリのparamsを処理する必要がありますか?私たちは必要ないと思う。 次のURLパターンは正常に動作するはずです: url(r '^ archive /'、view_to_handle)、 –

答えて

1

これはあなたのファイルである必要がありますmanifest.urls

urlpatterns = [ 
    url(r'^archive/?$', view_to_handle), 
] 
関連する問題