Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails when I add messages #135

Open
ClaudiuCreanga opened this issue May 14, 2019 · 2 comments
Open

Build fails when I add messages #135

ClaudiuCreanga opened this issue May 14, 2019 · 2 comments

Comments

@ClaudiuCreanga
Copy link

ClaudiuCreanga commented May 14, 2019

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.

@palewire
Copy link
Owner

I don't know the answer here. I've never used the messages framework.

@cmdlinebeep
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants