I have already checked this error on other * threads but don't find any error on my code. Perhaps I'm tired but it seems ok to me.
我已经在其他*线程上检查了这个错误,但是在我的代码上没有发现任何错误。也许我累了,但我觉得还行。
website.urls.py:
website.urls.py:
from django.conf.urls import patterns, include, url
#from django.contrib import admin
urlpatterns = patterns('',
# Register and Login
url(r'^inscription\.html$', 'membres.views.register'),
# List of users
url(r'^membres', include('membres.urls')),
)
membres.urls.py:
membres.urls.py:
from django.conf.urls import patterns, url
urlpatterns = patterns('membres.views',
url(r'^/(?P<slug>\d+)\.html$', 'view_user_public')
)
Of course I get :
我当然得到:
Using the URLconf defined in website.urls, Django tried these URL patterns, in this order:
^inscription\.html$
^membres ^/(?P<slug>\d+)\.html$
The current URL, membres/nicolas.html, didn't match any of these.
The inscription.html works properly. In the membres.urls.py
file, if I change r'^/(?P<slug>\d+)\.html$
to r'^\.html$
, the url membres.html
works properly and loads the view...
铭文。html工作正常。membres.urls。py文件,如果我改变r ' ^ /(? <蛞蝓> \ d +页)\。html $ r ' ^ \。html美元,进行初步的url。html工作正常,加载视图……
What's wrong with r'^/(?P<slug>\d+)\.html$
?
怎么了r ' ^ /(? <蛞蝓> \ d +页)\。html $ ?
Thanks a lot
非常感谢
1 个解决方案
#1
4
\d+
would match digits only. nicolas
is not composed of digits.
只匹配数字。尼古拉斯不是由数字组成的。
\w+
is what you're looking for.
你要找的就是w+。
More generally, [\w-]+
for slugs which typically contain hyphens.
更一般地说,[\w-]+用于通常含有连字符的蛞蝓。
#1
4
\d+
would match digits only. nicolas
is not composed of digits.
只匹配数字。尼古拉斯不是由数字组成的。
\w+
is what you're looking for.
你要找的就是w+。
More generally, [\w-]+
for slugs which typically contain hyphens.
更一般地说,[\w-]+用于通常含有连字符的蛞蝓。