当前网址,与任何这些都不匹配

Nic*_*ine 2 python django django-urls

我已经在其他stackoverflow线程上检查了此错误,但是在我的代码上找不到任何错误。也许我很累,但是对我来说似乎还可以。

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')),
)
Run Code Online (Sandbox Code Playgroud)

membres.urls.py:

from django.conf.urls import patterns, url

urlpatterns = patterns('membres.views',
    url(r'^/(?P<slug>\d+)\.html$', 'view_user_public')
)
Run Code Online (Sandbox Code Playgroud)

我当然知道:

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.
Run Code Online (Sandbox Code Playgroud)

inscription.html正常工作。在membres.urls.py文件中,如果更改r'^/(?P<slug>\d+)\.html$r'^\.html$,则url membres.html可以正常工作并加载视图...

这有什么错r'^/(?P<slug>\d+)\.html$

非常感谢

Yuj*_*ita 5

\d+仅匹配数字。nicolas不是由数字组成。

\w+ 是您要寻找的。

更一般地,[\w-]+对于通常包含连字符的段塞。