Search code examples
pythondjangodjango-authentication

Difference Between Reset Done and reset Complete in Django 2.0 Authentication Views


I'm looking at implementing user authentication to a Django project. I'm reading through the documentation. It mostly seems straightforward, but there's one thing that I don't understand.

Apparently the authentication includes eight views:

accounts/login/ [name='login']
accounts/logout/ [name='logout']
accounts/password_change/ [name='password_change']
accounts/password_change/done/ [name='password_change_done']
accounts/password_reset/ [name='password_reset']
accounts/password_reset/done/ [name='password_reset_done']
accounts/reset/<uidb64>/<token>/ [name='password_reset_confirm']
accounts/reset/done/ [name='password_reset_complete']

When implementing a password reset I assume that what I want to do implement accounts/password_reset/, which forwards the user an email. Then, I need to implement accounts/reset/<uidb64>/<token>/, which is where the user is directed to via the email. What I'm not clear on is what that should do when the user has updated their password successfully.

What's the difference between accounts/reset/done/ (or password_resest_complete) and accounts/password_reset/done/ (or password_reset_done)?


Solution

  • Good question. This is how they look like:

    class PasswordResetCompleteView(PasswordContextMixin, TemplateView):
        template_name = 'registration/password_reset_complete.html'
        title = _('Password reset complete')
    
        def get_context_data(self, **kwargs):
            context = super().get_context_data(**kwargs)
            context['login_url'] = resolve_url(settings.LOGIN_URL)
        return context
    
    class PasswordResetDoneView(PasswordContextMixin, TemplateView):
        template_name = 'registration/password_reset_done.html'
        title = _('Password reset sent')
    

    The main difference is that PasswordResetCompleteView passes the LOGIN_URL to your template context.