문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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')), 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top