Django will use the first URL pattern that matches. So in your urls.py
, add a pattern for accounts/login
before you include the urls from django-registration. All other URLs will be handled by django-registration.
Overiding URL pattern from a third party app
-
30-07-2022 - |
Frage
I am using django-registration app and I am implementing the Remember me functionality snippet
Basically, the registration app, needs you to define one URL only,
url(r'^accounts/', include('registration.backends.default.urls')),
under the hood, it defines default urls like /accounts/login
, /accounts/logout
, each of which points to django.contrib.auth.views
functions.
I need to overwrite the login()
function, as well as the accompanying URL.
So how do I overwrite URL accounts/login
in my urls.py
, keeping all the rest urls as default?
Lösung
Andere Tipps
You could try explicitly catching the accounts/login
url request before it hits your more general accounts/*
url catcher.
Maybe
# first catch your custom login
url(r'^accounts/login', include('my_custom_login.urls')),
# and everything else beginning with accounts/
url(r'^accounts/', include('registration.backends.default.urls')),
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow