Opened 11 years ago

Closed 11 years ago

#20840 closed New feature (wontfix)

Messaging framework to include namespaces

Reported by: Giggaflop Owned by: nobody
Component: contrib.messages Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Often I am working on building forms where a file is submitted and processed server side, I then return results upon the response as part of the django messaging framework.

I have often noticed that if the request fails but messages have been added to the messaging stack, that they will display at the next opportunity elsewhere on the site. much to the confusion of my users.

I propose adding namespaces to Django messaging such that whenever I'm pushing messages intended for specific sections of my site, they will only display there.

Example view code:

def push_global_message:
    # Note lack of a namespace, this is exactly as current functionality
    messages.warning(request, 'Three credits remain in your account.')

def push_targeted_message:
    # Note how i have included a namespace now to target the message and a TTL to expire the message
    messages.success(request, 'Your file upload has been received and will be processed shortly.', namespace="file_upload", ttl=10)

Example template code:

{% if messages %}
<ul class="messages">
    {% for message in messages.namespace.file_upload %}
    <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
    {% endfor %}
</ul>
{% endif %}

Change History (4)

comment:1 by anonymous, 11 years ago

Component: Uncategorizedcontrib.messages

comment:2 by Tim Graham, 11 years ago

My feeling is that this seems outside the scope of the messaging framework and that it won't be useful to a broad enough audience to be worthwhile, but I'll leave it open for a 2nd opinion.

comment:3 by Aymeric Augustin, 11 years ago

If the issue is "messages are displayed on the next page, regardless of which page it is", then this solutions requires too much work to be practical, in my opinion.

comment:4 by Tim Graham, 11 years ago

Resolution: wontfix
Status: newclosed

Giggaflop, if you disagree with us, feel free to raise the subject on django-developers.

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