Code

Changes between Version 19 and Version 20 of SessionMessages


Ignore:
Timestamp:
10/10/09 10:59:06 (5 years ago)
Author:
tobias
Comment:

potential messaging API

Legend:

Unmodified
Added
Removed
Modified
  • SessionMessages

    v19 v20  
    6464 
    6565== Potential API == 
    66 django-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]. 
     66 
     67The API is under discussion on the [http://groups.google.com/group/django-developers/browse_thread/thread/eba93088c649022b django-developers list].  Following are a few different iterations of what it might look like: 
     68 
     69{{{ 
     70from django.contrib import messages 
     71 
     72request.messages.add('message', messages.INFO) 
     73# or 
     74request.messages.add('message', classes=(messages.WARNING,)) 
     75# or 
     76request.messages.error('message') 
     77}}} 
     78 
     79Using messages in your template: 
     80 
     81{{{ 
     82{% if request.messages %} 
     83<ul class="messages"> 
     84        {% for message in request.messages %} 
     85        <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> 
     86        {% endfor %} 
     87</ul> 
     88{% endif %} 
     89}}} 
    6790 
    6891=== django-notify === 
     92django-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.  It is understood that, should django-notify be chosen, this may (and probably will) change prior to inclusion in the core. 
     93 
    6994Add the middleware to your MIDDLEWARE_CLASSES setting (after !SessionMiddleware): 
    7095{{{