#20610: Add a message level dict to
`contrib.messages.context_processors.messages`
----------------------------------+--------------------
Reporter: bmispelon | Owner: nobody
Type: New feature | Status: new
Component: contrib.messages | Version:
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------
It'd be nice if the provided context processor also added a dictionary of
message levels to the context.
This would allow something like this:
{{{#!html+django
{% for message in messages %}
{% if message.level == MESSAGE_LEVELS.SUCCESS %}...{% endif %}
...
{% endfor %}
}}}
Currently, one has to pass the message levels manually into the context,
or do something like this, which is brittle:
{{{#!html+django
{% if 'success' i nmessage.tags %}...{% endif %}
}}}
There should not be any backwards-compatibility issue and the change is
rather minimal.
I've attached a proof-of-concept patch. If there's interest, I'd be
willing to polish it up (mostly adding tests and documentation).
--
Ticket URL: <https://code.djangoproject.com/ticket/20610>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.9844cee0a3833d00cbe955865cfda209%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.