Im working with django-1.10
and would like to implement some notification behaviour for my application using pinax-notifications-4.0
.
I am following the quickstart for including this to the INSTALLED_APP
INSTALLED_APPS = [
# ...
"pinax.notifications",
# ...
]
then and the usage guide.
First is to create the notice type in heat/handler.py
from pinax.notifications.models import NoticeType
from django.conf import settings
from django.utils.translation import ugettext_noop as _
def create_notice_types(sender, **kwargs):
NoticeType.create(
"heat_detection",
_("Heat Detected"),
_("you have detected a heat record")
)
Secondly call the handler to create notices after the application is migrated. heat.apps.py
from .handlers import create_notice_types
from django.apps import AppConfig
from django.db.models.signals import post_migrate
class HeatConfig(AppConfig):
name = 'heat'
def ready(self):
post_migrate.connect(create_notice_types, sender=self)
finally include the appconfig to the heat.__init__.py
default_app_config = 'heat.apps.HeatConfig'
but when trying to run these:
python manage.py makemigrations pinax.notifications
I got this error: RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Then i try to change the pinax.notifications
to pinax-notifications
in the INSTALLED_APPS
. The server yield me this error: ImportError: No module named pinax-notifications
How to make this work?
I was able to solved it by changing the heat.apps.py file
to this.