Monday, March 09, 2009

Django-Notification Creating Notice Types issues

I was setting up Django-Notification for a project, and I was trying to create notice types like it mentions on their wiki . Their wiki says that you should add the following code to your file in your app.

from django.conf import settings
from django.db.models import signals
from django.utils.translation import ugettext_noop as _

if "notification" in settings.INSTALLED_APPS:
from notification import models as notification

def create_notice_types(app, created_models, verbosity, **kwargs):
.create_notice_type("friends_invite", _("Invitation Received"), _("you have received an invitation"))
.create_notice_type("friends_accept", _("Acceptance Received"), _("an invitation you sent has been accepted"))

.post_syncdb.connect(create_notice_types, sender=notification)
print "Skipping creation of NoticeTypes as notification app not found"

After trying lots of different things (dropping database and re syncing,etc) the management file wasn't getting picked up and it was quite annoying.

It turns out that if you have written custom management extensions and you have a management directory under your application it will ignore the file all together. So you need to add the code to the app/management/ file instead.

Once you have added the files you need to resync (make sure you remove notification_* tables first).

This makes total sense now, and I guess I shouldn't have taken the directions to literaly.

If you still can't get it to work, the other option is to just create a fixture and load the data that way.

Labels: , , ,