Skip to content Skip to sidebar Skip to footer

Django Messages Being Displayed Twice

I'm using Django's message framework, and I have a very odd problem where my messages are being displayed twice in the template, even though {{messages|length}} is 1 My view if req

Solution 1:

Turns out this was a template inheritance issue. Double check and make sure you don't have the same block in two different templates.

Solution 2:

While this answer is for a different question, I was having this issue and it helped me resolve it.

To summarize, the following code can be added to settings.py:

MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'

This changes the messages from being stored in CookiesStorage to SessionStorage, which in some cases are more reliable and prevent double displaying of messages, or not displaying at all.

Post a Comment for "Django Messages Being Displayed Twice"