简体   繁体   中英

Why does the first element not work?

In my urls.py file, the first element doesn't work at all. What the hell?

Here's my original urls.py file:

urlpatterns = patterns(
    url(r'^admin/', include(admin.site.urls)),
    url(r'^home/$', HomeView.as_view(), name='home'),
    url(r'^$', IndexView.as_view(), name="index"),
)

Set up like that, I can't access /admin/, modifying it to...

urlpatterns = patterns(
    url(r'^wutlolwutwut/', include(admin.site.urls)),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^home/$', HomeView.as_view(), name='home'),
    url(r'^$', IndexView.as_view(), name="index"),
)

It now does. The Debug from the 404 on the original doesn't show the admin regex.

Proof with original , and with modified .

What is happenning?

SOLVED: pattern() function takes a string prefix as it's first argument along n number of url() calls, which is what bugged my urls.py

patterns函数的第一个参数应该是一个字符串,该字符串充当其余参数的前缀。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM