Reputation: 8648
When using PasswordChangeView
in Django auth:
path('password_change/', auth_views.PasswordChangeView.as_view(
template_name='accounts/password_change.html',
success_url='accounts/password_change_success.html'),
name='password_change'),
Does the success_url
override the PasswordChangeDoneView
, as it does when success_url
is passed in PasswordResetView
and overrides PasswordResetDoneView
? From the docs:
PasswordResetDoneView This view is called by default if the PasswordResetView doesn’t have an explicit success_url URL set.
The docs are silent on the behaviour between success_url
in PasswordChangeView
and PasswordChangeDoneView
.
Upvotes: 1
Views: 940
Reputation: 41
For future reference: Django was not using my custom template because I used the same name for the html file. After changing it, it used the custom template.
Upvotes: 0
Reputation: 477641
A success_url
[Django-doc] is the URL to which it redirects (through a 302 HTTP response) in case the form was successful.
In the PasswordChangeView
[Django-doc], we see in the source code [GitHub] that it uses:
class PasswordChangeView(PasswordContextMixin, FormView): form_class = PasswordChangeForm success_url = reverse_lazy('password_change_done') template_name = 'registration/password_change_form.html' title = _('Password change') # ...
So in case you do not specify a success_url
yourself, it will redirect to a view with the name password_change_done
.
Upvotes: 2