Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug a 'Not all temporary messages could be stored' value error in django?

Tags:

python

django

I have a class based view that calls info() when a form is successfully posted. After reading the messaging framework document and commenting out the info call I'm sure that its the culprit of the 'Not all temporary messages could be stored' error.

I can't figure out what happens after the info call that causes the error in the post title, though.

like image 331
landon Avatar asked Apr 04 '14 00:04

landon


People also ask

How do I clear Django messages?

clear() function. Show activity on this post. You need to iterate through the messages for your current set of messages as retrieved from the 'get_messages' method. You can use this code anywhere you want to clear the messages before setting new ones or where you want to simply clear all messages.

How do you use contrib messages in Django?

Import messages from django. contrib at the top of the file then go to the view function where you wish to add the message(s). In this case, it's a contact view that needs a Django success message and a Django error message. Add a success message just before the return redirect ("main:homepage") stating "Message sent."


2 Answers

Turns out the number of messages stored in the client-side cookie was maxed out. When the server tried to pack additional cookies into the client's cookie, it failed and raised the 'Not all temporary messages could be stored' value error.

I fixed this by making sure messages could be displayed in the browser by adding a

{% block messages %}

to the website's base template.

like image 192
landon Avatar answered Sep 28 '22 22:09

landon


So this issue troubled me for a while. So in case you want your messages to be rendered on the browser, this case maybe when you are developing, debugging or want a sequential message log the you can update the django settings.py file

Change MESSAGE_STORAGE variable to:

MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'

this way it will hit the CookieStorage and then fallback to base storage.

Other alternative can be to store it in session

MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
like image 40
Nishant Patel Avatar answered Sep 28 '22 22:09

Nishant Patel