#28644 closed Bug (invalid)
Messages not Displaying After Redirect
Reported by: | Nirmal Natarajan | Owned by: | nobody |
---|---|---|---|
Component: | contrib.messages | Version: | 1.11 |
Severity: | Normal | Keywords: | messages |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have this piece of code in my view:
if _user.objects.user_exists(_email): auth.logout(request) messages.success(request, 'You already hold a verified account with us. Please login.') return redirect('accounts:login')
and this in my template:
{% if messages %} {% for message in messages %} <div>{{ message }}</div> {% endfor %} {% endif %}
This sadly wouldn't work. But if I change redirect('accounts:login') to render(request, 'accounts/login.html'), the message would display.
And for the message storage, I am using:
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
Change History (3)
comment:1 by , 7 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:2 by , 7 years ago
Thank you, Tim Graham. Your confirmation helped me look at other places and found that the session cookie's domain setting was the problem. So obviously the production setting was failing while developing on localhost.
comment:3 by , 7 years ago
Resolution: | needsinfo → invalid |
---|
Note:
See TracTickets
for help on using tickets.
I can't reproduce the issue given the details you provided. Ideally, you could debug the problem enough to explain why Django is at fault. If you can't do that, you can ask for help in confirming the bug using our support channels. Please reopen with a minimal project that reproduces the issue if a bug is confirmed. Thanks!