Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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


I have this piece of code in my view:

if _user.objects.user_exists(_email):
    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:


Change History (3)

comment:1 by Tim Graham, 7 years ago

Resolution: needsinfo
Status: newclosed

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!

comment:2 by Nirmal Natarajan, 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 Tim Graham, 7 years ago

Resolution: needsinfoinvalid
Note: See TracTickets for help on using tickets.
Back to Top