How to show messages in Python?
If you are using render() for views.py you could add a boolean value to the context
i.e render(request "template_name.html", {"is_auth": True})
Assumedly you are doing auth in the serverside so you could tackle it this way.
Not a great fix but might help.
I am new to Django and trying to create an Application.
My scenario is:
I have a form on which there are many items and user can click on Add to Cart to add those item to Cart. I am validating if the user is logged in then only item should be added to Cart else a message or dialogue box must appear saying please login or sign up first.
Although I was able to verify the authentication but the somehow not able to show the message if user is not logged in.
For now I tried the below things:

Using session messages, but somehow it needs so many places to take care when to delete or when to show the message
Tried using Django Messages Framework, I checked all the configuration in settings.py and everything seems correct but somehow not showing up on HTML form

Does anyone can help me here?
I want to know a approach where I can authenticate the user and if user is not logged in a dialogue box or message should appear saying Please login or Signup. It should go when user refreshes the page.