Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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')), 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top