django-admin-notifications

Software Screenshot:
django-admin-notifications
Software Details:
Version: 0.6.3
Upload Date: 11 May 15
Developer: Andy Baker
Distribution Type: Freeware
Downloads: 12

Rating: 3.0/5 (Total Votes: 1)

django-admin-notifications is a simple Django app to allow apps to register notifications that can be displayed in the admin via a template tag.

Installation:

Add 'admin_notifications' to INSTALLED_APPS

Basic usage:

Customize whichever of your admin templates you which to display the notifications thus.

load the template tags at the start of the template:

{% load notification_tag %}

add the tag to your template. I customised the admin index template and placed the tag before the 'content-main' DIV like thus:

{% block content %}
< !-- here's the tag you add -- >
{% error_notifications %}
< div id=''content-main" >


in urls.py:

import admin_notifications
admin_notifications.autodiscover()


This looks in each app for a file called 'notifications.py and registers it if it exists.

Notifications files can contain as many functions as you like. Each one should return a string which can contain HTML and each one needs to be registered using admin_notifications.register

If you return an empty string then no notification is shown.

Notifications functions are called every time the admin template is rendered so avoid doing heavy calculations in the notification.

An example notifications.py might look like this:

import admin_notifications
from models import Url
def notification():
 broken_links = Url.objects.filter(status=False).count()
 if broken_links:
 return "You have %s broken link%s.
You can view or fix them using the Link Manager." % (broken_links, "s" if broken_links>1 else "")
 else:
 return ''


admin_notifications.register(notification)

Github page: http://github.com/andybak/django-admin-notifications/

Requirements:

  • Python
  • Django

Other Software of Developer Andy Baker

django-linkcheck
django-linkcheck

20 Feb 15

Comments to django-admin-notifications

Comments not found
Add Comment
Turn on images!