Execute javascript code on page only when redirected - DJANGO

0

Good afternoon guys, how are you? There goes my first question!

I've been learning Django for less than a month, I'm doing a practical project, this project is a login screen. It already works perfectly, user puts the right password, it goes to private page and if it goes wrong, it is redirected again to login screen!

But now, I want to put messages on the login screen. Example, if the guy entered the wrong password, a message will be displayed (Incorrect user or password), I chose toastr to do this. I created a function in JS that displays alert alerts (type), I already tested this function by putting it in an onclick of a button and it was perfect.

Now I wanted to know how do I call her in the django view, because that's where I check whether the user was authenticated or not.

If you have been authenticated: Success alert and redirects to private page if no wrong user alert or password

The problem is that I do not know how to call this function within that if. :

Can anyone help?

Sorry for the large text, I tried to be as descriptive as possible!

    
asked by anonymous 08.05.2018 / 22:15

0 answers