django-notices

A message notification system for Django
Download

django-notices Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Price:
  • FREE
  • Publisher Name:
  • David Cramer
  • Publisher web site:
  • http://code.google.com/u/dcramer/

django-notices Tags


django-notices Description

A message notification system for Django django-notices is a replacement for the built-in message notification system in Django. The plugin works off of the current session rather than a database store, which means it also works for Anonymous users, and does not require doing database queries each time you need to access it.Installation:To install the latest stable version:sudo easy_install django-noticesTo install the latest development version (updated quite often):git clone git://github.com/dcramer/django-notices.gitcd django_noticessudo python setup.py installUsage:The easiest way to use django-notices, is simply by adding it to your settings.py:INSTALLED_APPS = ( '...', 'django_notices',)MIDDLEWARE_CLASSES = ( 'django_notices.middleware.NoticeMiddleware',)TEMPLATE_CONTEXT_PROCESSORS = ( 'django_notices.context_processors.notices',)Once you've done this you'll now have access to two important pieces of the notice system, the notices context variable, and request.notices.The first thing you're going to want to do, is add a handler for notices within your templates:< div id="notices" > < ul > {% for notice in request.notices %} < li class="notice notice-{{ notice.level_label }}" >{{ notice.message|escape }}< /li > {% endfor %} < /ul >< /div >What this does, is on each page load, displays each active notice and clears it from the session.Now once you can display your notices, you'll need to begin adding them. This is also made verydef my_view(request): request.notices.warn('This is a warning')There are several methods available in the built-in handler:NoticeHandler.warnNoticeHandler.errorNoticeHandler.infoNoticeHandler.debugNoticeHandler.successBy default, DEBUG level notices are not shown. To change this, you can adjust the NOTICE_LEVEL setting in your settings.py:from django_notices import DEBUGNOTICE_LEVEL = DEBUG Requirements: · Django · Python


django-notices Related Software