django-bakery
django-bakery copied to clipboard
Build fails when I add messages
The site works but when I try to bake it, it throws an error:
AttributeError: 'WSGIRequest' object has no attribute '_messages'
During handling of the above exception, another exception occurred
django.contrib.messages.api.MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware
This happens because in one of my views I add a message
from django.contrib import messages
messages.add_message(request, messages.INFO, "Hello world.")
I have all the required apps installed and it works when running the site normally:
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
Doesn't bakery support showing messages? The use case is that you want to show messages that are not dynamic (hey, I delivered you this site, but it has these errors and these warnings). Obviously I can do it by storing the messages in a variable and not use the django messages framework. Since they are not dynamic, it isn't much work, but would be nicer to go the django way.
I don't know the answer here. I've never used the messages framework.
For anyone finding this later, I wouldn't see how this could work without a server. The Django messages framework either uses sessions for logged in users or cookies. In both cases a server is performing some logic. How would it work for an error message one user sees to be stored in a CDN?
Essentially, messages are dynamic.