1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #20610: Added a message level dict to contrib.message context processor.

This commit is contained in:
Baptiste Mispelon
2013-10-28 21:52:11 +01:00
parent e9a356a695
commit 9fde42a69a
5 changed files with 40 additions and 1 deletions

View File

@@ -196,6 +196,22 @@ Even if you know there is only just one message, you should still iterate over
the ``messages`` sequence, because otherwise the message storage will not be cleared
for the next request.
.. versionadded:: 1.7
The context processor also provides a ``DEFAULT_MESSAGE_LEVELS`` variable which
is a mapping of the message level names to their numeric value::
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>
{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}Important: {% endif %}
{{ message }}
</li>
{% endfor %}
</ul>
{% endif %}
Creating custom message levels
------------------------------

View File

@@ -203,6 +203,9 @@ Minor features
follow the :setting:`SESSION_COOKIE_SECURE` and
:setting:`SESSION_COOKIE_HTTPONLY` settings.
* The :ref:`messages context processor <message-displaying>` now adds a
dictionary of default levels under the name ``DEFAULT_MESSAGE_LEVELS``.
:mod:`django.contrib.redirects`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^