views:

20

answers:

0

I've made a template tag to display a login form on various pages of my site. The idea behind that is also, that after logging in you see the same page/content as before and you don't get redirected to another page.

I could do form validation & logging-in without any problems in the template-tag's render method, but the problem is, that then the user get's logged in when this template node is rendered, which is too late (eg. if you have menu items that are only shown for logged in users and are rendered BEFORE the form, they will only appear after the page has been reloaded). Therefore I'm now posting the form to django's default log in view and redirect afterwards to the page previously displayed, which works flawlessly except that i cannot get any form validation for that then (the redirect removes post/get variables from the request). I was thinking now to do the login process via a middleware, which I think should work, but it seems unnecessary complicated and odd for me... Is there any other way round this?