Changes between Version 15 and Version 16 of SessionMessages


Ignore:
Timestamp:
Oct 10, 2009, 11:52:12 AM (15 years ago)
Author:
Tobias McNulty
Comment:

add API for django-notify

Legend:

Unmodified
Added
Removed
Modified
  • SessionMessages

    v15 v16  
    5454
    5555Please update this table with new options or corrected information as necessary.
     56
     57== Potential API ==
     58django-notify is the current front-runner in terms of technical features so a sampling of the potential API is included below.  Feel free to include the API(s) of other solutions as well for comparison.  Discussion of the API should take place on the [http://groups.google.com/group/django-developers/browse_thread/thread/eba93088c649022b django-developers list].
     59
     60=== django-notify ===
     61Add the middleware to your MIDDLEWARE_CLASSES setting (after !SessionMiddleware):
     62{{{
     63    'django_notify.middleware.NotificationsMiddleware',
     64}}}
     65
     66Add the context processor into your TEMPLATE_CONTEXT_PROCESSORS setting:
     67{{{
     68    'django_notify.context_processors.notifications',
     69}}}
     70
     71Add a temporary notification message like this:
     72{{{
     73    request.notifications.add('Hello world.')
     74    # You can optionally provide a string containing tags (which is usually represented as HTML classes for the message).
     75    request.notifications.add('Your rating is over 9000!', 'error')
     76}}}
     77
     78Use notifications in your template:
     79{{{
     80{% if notifications %}
     81<ul class="notifications">
     82        {% for message in notifications %}
     83        <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
     84        {% endfor %}
     85</ul>
     86{% endif %}
     87}}}
Back to Top