Putting a django login form on every page

Posted by asciitaxi on Stack Overflow See other posts from Stack Overflow or by asciitaxi
Published on 2010-04-29T00:31:18Z Indexed on 2010/04/29 0:37 UTC
Read the original article Hit count: 900

Filed under:
|
|

I'd like the login form (AuthenticationForm from django.contrib.auth) to appear on every page in my site if the user is not logged in. When the user logs in, they will be redirected to the same page. If there is an error, the error will be shown on the same page with the form.

I suppose you'd need a context processor to provide the form to every template. But, then you'd also need every view to handle the posted form? Does this mean you need to create some middleware? I'm a bit lost.

Is there an accepted way of doing this?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-auth