I’m using Django registration to manage the registration and login / logout together with Django’s auth system. It’s working fine, I have a base template where I have put a ‘login’ link that takes the user to another page to login. I’d like to replace this link with the actual login form (username / password) so the form appears directly in every page. Any suggestions?
I’m using Django registration to manage the registration and login / logout together with
Share
You can use an inclusion template tag to build a custom tag that looks like:
You might want to pass this tag the
request.get_absolute_uriso that it can use it in a?next={{ request.get_absolute_uri }}parameter to the login view so that the user can be redirected to the current page after login.This way, you can put the login form anywhere you want in any template without violating the DRY principles. You can even embed it in your base template using something like: