Je suis en train de travailler avec django-1.10
et j'aimerais mettre en place un comportement de notification pour mon application en utilisant pinax-notifications-4.0
.L'intégration des notifications pinax a échoué dans l'application django
Je suis la quickstart pour inclure cela au INSTALLED_APP
INSTALLED_APPS = [
# ...
"pinax.notifications",
# ...
]
alors et le guide usage.
premier est de créer le type de notification chaleur/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")
)
appellent le second gestionnaire pour créer des avis après l'application est migré. 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)
comprennent enfin le appconfig au heat.__init__.py
default_app_config = 'heat.apps.HeatConfig'
mais en essayant de courir ces:
python manage.py makemigrations pinax.notifications
Je suis cette erreur: RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Ensuite, j'essaie de changer le pinax.notifications
en pinax-notifications
dans le INSTALLED_APPS
. Le serveur me cède cette erreur: ImportError: No module named pinax-notifications
Comment faire pour que cela fonctionne?
Avez-vous 'django.contrib.sites' dans votre' INSTALLED_APPS'? –
j'ai ajouté et je change le 'pinax.notifications' à' pinax' et maintenant son fonctionnement je ne sais pas pourquoi encore mais les documents indique clairement que 'pinax.notifications' –
Vu aussi. –