python - RemovedInDjango19Warning: Model doesn't declare an explicit app_label -
have gone through
django 1.9 deprecation warnings app_label
but answers couldn't fix problem, asking again.
i have app added installed_apps in settings.
when ever run manage.py runserver
, warning,
[trimmed path project]/catalog/models.py:9: removedindjango19warning: model class catalog.models.category doesn't declare explicit app_label , either isn't in application in installed_apps or else imported before application loaded. no longer supported in django 1.9. class category(models.model):
the code app,
signals.py
from django.db.models.signals import post_save django.dispatch import receiver models import category @receiver(post_save, sender=category) def somesignal(sender, **kwargs): pass
apps.py
from django.apps import appconfig class catalogconfig(appconfig): name = 'catalog' verbose_name = 'catalogue'
init.py
import signals default_app_config = 'catalog.apps.whosconfig'
django version 1.8.2 on python 2.7.8
you importing models.py before app configuration run.
to fix it, import , configure signals in catalogconfig.ready
method.
like this:
signals.py
def somesignal(sender, **kwargs): pass
apps.py
from django.apps import appconfig django.db.models.signals import post_save class catalogconfig(appconfig): name = 'catalog' verbose_name = 'catalogue' def ready(self): .signals import somesignal post_save.connect( receiver=somesignal, sender=self.get_model('category') )
you may want check ready method in documentation
Comments
Post a Comment