[Answer]-Django login form in header

1đź‘Ť

âś…

Thanks to some feedback here and on Pythonanywhere, I’ve been able to solve this issue.

I had narrowed it down to a problem passing the HTML since the login works correctly on the /accounts/login/ page. I found out that the logging in from the header worked only on the /accounts/login/, but the other pages it did not, so that meant there definitely was a problem passing to the page.

The problem ended up being that I had the input property named “action”, when it should have been “formaction”. I knew it was really close and it would be something dumb like that 🙂

👤awwester

0đź‘Ť

There’s absolutely nothing wrong with setting your form’s action property to a URL that is different than the current view being viewed in order to perform your login.

You can always bring the user directly back to the page they were viewing by setting the next hidden field in your form to the value of the current URL, then passing that to the built-in login view, or redirect them somewhere else…it’s entirely up to you.

Leave a comment