Search code examples
pythondjangodjango-registration

Overiding URL pattern from a third party app


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?


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.