Permalink
Browse files

Updated docs to use Django's app cache to detect if notification is i…

…nstalled

git-svn-id: http://django-notification.googlecode.com/svn/trunk@128 590c3fc9-4838-0410-bb95-17a0c9b37ca9
  • Loading branch information...
1 parent 11505a0 commit 4cd2d9cf2405cbcf8fc852f59ab1569155741c99 @jezdez jezdez committed Jan 4, 2009
Showing with 9 additions and 5 deletions.
  1. +9 −5 docs/usage.txt
View
@@ -26,17 +26,18 @@ One good way to automatically do this notice type creation is in a
``management.py`` file for your app, attached to the syncdb signal.
Here is an example::
- from django.db.models import signals
+ from django.db.models import signals, get_app
+ from django.core.exceptions import ImproperlyConfigured
try:
- from notification import models as notification
+ notification = get_app("notification")
def create_notice_types(app, created_models, verbosity, **kwargs):
notification.create_notice_type("friends_invite", "Invitation Received", "you have received an invitation")
notification.create_notice_type("friends_accept", "Acceptance Received", "an invitation you sent has been accepted")
signals.post_syncdb.connect(create_notice_types, sender=notification)
- except ImportError:
+ except ImproperlyConfigured:
print "Skipping creation of NoticeTypes as notification app not found"
Notice that the code is wrapped in a try clause so if django-notification is
@@ -135,9 +136,12 @@ a notice.
For example::
+ from django.db.models import get_app
+ from django.core.exceptions import ImproperlyConfigured
+
try:
- from notification import models as notification
- except ImportError:
+ notification = get_app('notification')
+ except ImproperlyConfigured:
notification = None
and then, later::

0 comments on commit 4cd2d9c

Please sign in to comment.