Class-based LoginView #502

wants to merge 3 commits into


None yet

2 participants


Here is a proposal to replace django.contrib.auth.views.login by some class-based view.

The proposed implementation contains:

  • a LoginView class, which focuses on providing a clean class based on FormView. As an example, it uses FormView's standard "success_url" instead of former "redirect_to" argument.

  • a BackwardCompatibleLoginView class, which focuses on backward compatibility. As an example, if "redirect_to" is provided, it uses it instead of LoginView's "success_url".

  • a login function, which makes it possible to use django.contrib.auth.views.login as before. It is a pre-configured BackwardCompatibleLoginView.

  • a login_decorator decorator, which is just a shorcut to standard decorators for login views.


Created ticket about class-based login view.


Looking at related, I see I guess I can rebase this pull request on @mjtamlyn's work.

Django member

Yeah there's a CBV version of LoginView in there which pretty much works. There were some particular issues with the original implementation that at least @andrewgodwin didn't like which are commented on that issue. It's definitely too late for this to get in 1.5 but I'd love to see it in 1.6. I kind of ran out of steam with getting it polished.

It needs a decent accepted spec of how we're going to implement the new CBVs and a core dev on side to get it going. I think this is ideal sprint material (DjangoConEU 2013 if not before?). I'm also going to cc @bmispelon in here as he wrote the original versions (all I've done is attempt to bring them up to speed).


Closing this pull-request: duplicate of

@benoitbryon benoitbryon closed this Nov 7, 2012
@benoitbryon benoitbryon referenced this pull request in mjtamlyn/django Nov 7, 2012

Minor improvements proposal #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment