question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document how this conflicts/integrates with `contrib.auth` URLs

See original GitHub issue

Let’s say I have a pretty typical Django project with django.contrib.auth URLs, like this:

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

As you can see from the source code of auth.urls, it provides these URLs:

  • login
  • logout
  • password_change
  • password_change_done
  • password_reset
  • password_reset_done
  • password_reset_confirm
  • password_reset_complete

This is exactly the same list as the URLs provided by registration.auth_urls, just with the auth_ prefix:

  • auth_login
  • auth_logout
  • auth_password_change
  • auth_password_change_done
  • auth_password_reset
  • auth_password_reset_done
  • auth_password_reset_confirm
  • auth_password_reset_complete

However, if I search for auth_login, auth_logout, or any of these previous URL names, I cannot find any of them documented.

All the auth_ URLs point to django.contrib.auth views, so it doesn’t seem like auth_ views are necessary. They use the same template names (registration/login.html, etc.) Interesting, the regexes are slightly different (r'^password/change/$' instead of r'^password_change/$').

It seems like this should be the suggested URL config:

urlpatterns = [
    url(r'^accounts/', include('django.contrib.auth.urls')),
    url(r'^accounts/', include('registration.backends.hmac.urls')), # change backend if desired
    # ...
]

That way, the existing registration/login.html template does not need to be changed, and {% url "login" %} does not need to be changed to {% url "auth_login" %}.

Is my understanding correct? If so, I would be glad to submit a documentation pull request.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ubernostrumcommented, Jun 4, 2017

Just directly using the contrib.auth URLs would be backwards-incompatible; I’m leaving this open to do in django-registration 3.0 since I can break backwards compatibility there. For now, registration.auth_urls will emit a DeprecationWarning.

1reaction
ubernostrumcommented, Jan 22, 2018

2.4 is out, master is now 3.0 prep, and the built-in auth URLconf has been removed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django.contrib.auth
auth ¶. This document provides API reference material for the components of Django's authentication system. For more details on the usage of these...
Read more >
Using App name with Django.contrib.auth views
I have added in the {% url 'account:password_change_done; %} in my html file. The URL is directed correctly but I got a HTTP...
Read more >
Inbuilt User Authentication with Django — Login, and Logout
Create a URL in the project level url.py file, which includes the django.contrib.auth.urls . djangoauth/urls.py from django.conf.urls import url, include
Read more >
django.contrib.auth 'Specifying a namespace in include ...
I am using Django 2.0.4. Error code: File "/Users/User/PycharmProjects/django 0-1 login test/auth0login/urls.py ...
Read more >
Quick start guide — django-registration 3.3 documentation
contrib.auth.urls URLconf. The following URL names are defined by django_registration.backends.activation.urls : django_registration_register is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found