gpt4 book ai didi

python - 当前 URL 与这些中的任何一个都不匹配

转载 作者:行者123 更新时间:2023-11-28 21:52:41 30 4
gpt4 key购买 nike

我已经在其他 stackoverflow 线程上检查过这个错误,但在我的代码中没有发现任何错误。也许我累了,但我觉得还好。

网站.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')),
)

成员.urls.py:

from django.conf.urls import patterns, url

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

当然我明白了:

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.

inscription.html 工作正常。在membres.urls.py文件,如果我更改 r'^/(?P<slug>\d+)\.html$r'^\.html$ , 网址 membres.html正常工作并加载 View ...

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

非常感谢

最佳答案

\d+ 只会匹配数字。 nicolas 不是由数字组成的。

\w+ 就是您要查找的内容。

更一般地说,[\w-]+ 用于通常包含连字符的 slug。

关于python - 当前 URL 与这些中的任何一个都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27970182/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com