Solution 1 :

I think there is no other solution that override django.contrib.auth classes for make your custom urls if you are using the default.

Overriding the default does not work because auth code use the original urls.

With package like django-allauth, you can make custom urls, but with Django-auth, it is not possible.
then I think it goes rather quickly to copy paste the classes of and to overload the different urls

I am interesting if someone else has a better and elegant solution of this problem too

Solution 2 :

Typically the login url is specified in the LOGIN_URL setting [Django-doc]:


# …

LOGIN_URL = reverse_lazy('accounts:login')

In your views where you need the LOGIN_URL, you then import this from the settings, so:

from django.conf import settings

class PasswordChangeView(PasswordContextMixin, FormView):
    form_class = PasswordChangeForm
    success_url = settings.LOGIN_URL
    template_name = 'registration/password_change_form.html'
    title = _('Password change')

This thus makes it convenient to plug in a different view name.

Problem :

I made an app with app_name = ‘accounts’ in of the django and created signup/login pages there using the built-in signup function.

Now I need to change all the class details of the success_url, for instance from:




but overwriting the original is not a good practice.
I’m a python beginner and struggling with this problem already for a month..

how can I achieve this?

What I attemptd was making subclasses in my views inherent from each of the class in django.contrib.auth.views.

I even tried putting try/except method with except ‘NoReverseMatch:’ but the function itself did not exist.


Comment posted by Willem Van Onsem

Where did you use

Comment posted by YOUROUS

@WillemVanOnsem ‘login’ was used by my original class in but they are usually part of the preset in django.contrib.auth.urls. like this: class PasswordChangeView(PasswordContextMixin, FormView): form_class = PasswordChangeForm success_url = reverse_lazy(“password_change_done”) template_name = “registration/password_change_form.html” title = _(“Password change”)

Comment posted by YOUROUS

How is that possible to overload a different!?

Comment posted by Lucas Grugru

@YOUROUS i said overriding does not work so it is not possible so i do not understand your question ? You can make a different with same url name as django.contrib.auth and set in your main urls.pŷ instead of default django.contrib.auth.urls but you cannot change the name, only the path so it cannot resolve your problem

Comment posted by YOUROUS

Excuse me I was asking about the django-allauth thing because it’s not familiar to me, but I get it that there’s no easy solution for this override stuff yet right

Comment posted by…

@YOUROUS you can find some informations on the official doc:

Comment posted by YOUROUS

I suppose this will also work 100%, however what I am telling here is changing all the success_url path to the app_name-related path including ‘password_change_done’, ‘password_reset_done’ and ‘password_reset_complete’. I am sorry I gave you the bad example by using ‘login’. Is there something also like ‘PASSWORD_CHANGE_DONE_URL’?

Comment posted by Lucas Grugru

The question is about change all defaull url of django.contrib.auth, not just LOGIN_URL