[Answered ]-How to raise a note on the html page

1👍

Store your statement that you want to display on the template login.html in a variable (“state” here) like this:

def home(request):
    templatename="login.html"
    if request.method=="POST":
        u=request.POST.get("username")
        p=request.POST.get("password")
        user=authenticate(username=u, password=p)
        if user is not None:
            if user.is_active:
                state="This User is valid, active and authenticated"
                login(request,user)
                return HttpResponseRedirect("/welcome/")
            else:
                state="This User is valid but the account has been disabled"
        else:
            state="The Username and Password entered were incorrect"
    else:
        user=None
    return render_to_response(templatename,{'user': user,'state':state},RequestContext(request))

Pass the state in the dictionary passed to render_to_response().
Access the state in the login.html page as {{state}}.
Your work is done.

1👍

use instead of

print("This User is valid but the account has been disabled")

this

return HttpResponse("This User is valid but the account has been disabled")

here is Why

Leave a comment