What's reason for Django contrib.auth duplicated URL routes?

98 views Asked by At

Django newbie here - Futzing around the contrib.auth module, noticed a couple places where there were additional routes defined:

From /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.

What does "reliable view deployment for test purposes" mean, and what does "deploy these URLs elsewhere" mean in this context?

1

There are 1 answers

0
Alasdair On

The url patterns are used in Django's tests, e.g. here and here. It's reliable because it's including the same set of views mapped to the same urls everywhere.

You can also use these urls in your own project (i.e. deploy these urls elsewhere):

urlpatterns = [
    ...
    url('^', include('django.contrib.auth.urls'))
]

See the docs for more information. However, if you want more customization (e.g. use the url /signin/ instead of /login/), then you need to add individual url patterns to your urls.py, instead of including the entire django.contrib.auth.urls.