python - Django contrib.auth 重复 URL 路由的原因是什么?

标签 python django django-authentication

这里是 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 的测试,例如herehere 。它很可靠,因为它包含映射到各处相同 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/

相关文章:

django - session 被 django-all auth 重置

python - 访问键内的索引/值 (Python)

python - 如何在 django 管理站点中使用 django-select2 小部件?

python - Django 加密 key 完整性

python - 在django中删除确认

django - Django-用户管理员-将组添加到list_display

python - 为什么 user.is_authenticated 在注销后断言为真

python - --debug Python 中的命令行参数

python - 矩阵计算 Python

python - 我在 train_score 中遇到错误,有人可以解决吗?