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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Technically, it's backwards incompatible for people who have
"MESSAGE_LEVELS" in their context. That's minor, but it should be
mentioned in the release notes.
--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:1>
* needs_docs: 0 => 1
* has_patch: 0 => 1
* version: => master
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:2>
* needs_docs: 1 => 0
* needs_tests: 1 => 0
Comment:
Here's a pull request with tests and documentation:
https://github.com/django/django/pull/1822
--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:3>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:4>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"9fde42a69a56cb6c8cdfd67b07c67a1b97638f12"]:
{{{
#!CommitTicketReference repository=""
revision="9fde42a69a56cb6c8cdfd67b07c67a1b97638f12"
Fixed #20610: Added a message level dict to contrib.message context
processor.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:5>
Comment (by Claude Paroz <claude@…>):
In [changeset:"79e4a189f3b17b5a7426f889c4412126eb169256"]:
{{{
#!CommitTicketReference repository=""
revision="79e4a189f3b17b5a7426f889c4412126eb169256"
[1.7.x] Updated the messages context processor docs
Refs #20610.
Backport of 7951f125e frmo master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20610#comment:6>