这里是 Django 新手 - 围绕 contrib.auth 模块进行 Futzing,注意到几个地方定义了其他路由:
来自/django/contrib/auth/urls.py
# The views used below are normally mapped in django.contrib.admin.urls.py
# This URLs file is used to provide a reliable view deployment for test purposes.
# It is also provided as a convenience to those who want to deploy these URLs
# elsewhere.
在此上下文中,“用于测试目的的可靠 View 部署”是什么意思,以及“在其他地方部署这些 URL”是什么意思?
最佳答案
URL 模式用于 Django 的测试,例如here和 here 。它很可靠,因为它包含映射到各处相同 URL 的同一组 View 。
您还可以在自己的项目中使用这些网址(即在其他地方部署这些网址):
urlpatterns = [
...
url('^', include('django.contrib.auth.urls'))
]
参见the docs了解更多信息。但是,如果您想要更多自定义(例如,使用 url /signin/
而不是 /login/
),那么您需要向 urls.py 添加单独的 url 模式,而不是包含整个 django.contrib.auth.urls
。
关于python - Django contrib.auth 重复 URL 路由的原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30886689/