| 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 | |
| | 67 | The 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 | {{{ |
| | 70 | from django.contrib import messages |
| | 71 | |
| | 72 | request.messages.add('message', messages.INFO) |
| | 73 | # or |
| | 74 | request.messages.add('message', classes=(messages.WARNING,)) |
| | 75 | # or |
| | 76 | request.messages.error('message') |
| | 77 | }}} |
| | 78 | |
| | 79 | Using 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 | }}} |