python - Django 1.9 deprecation warnings app_label -


i've updated django v1.8, , testing local setup before updating project , i've had deprecation warning i've never seen before, nor make sense me. may overlooking or misunderstanding documentation.

/users/neilhickman/sites/guild/ankylosguild/apps/raiding/models.py:6: removedindjango19warning: model class ankylosguild.apps.raiding.models.difficulty 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 difficulty(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/raiding/models.py:21: removedindjango19warning: model class ankylosguild.apps.raiding.models.zone 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 zone(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/raiding/models.py:49: removedindjango19warning: model class ankylosguild.apps.raiding.models.boss 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 boss(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/raiding/models.py:79: removedindjango19warning: model class ankylosguild.apps.raiding.models.item 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 item(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/forum/models.py:14: removedindjango19warning: model class ankylosguild.apps.forum.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):  /users/neilhickman/sites/guild/ankylosguild/apps/forum/models.py:36: removedindjango19warning: model class ankylosguild.apps.forum.models.comment 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 comment(scoremixin, profilemixin, models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/forum/models.py:64: removedindjango19warning: model class ankylosguild.apps.forum.models.forum 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 forum(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/forum/models.py:88: removedindjango19warning: model class ankylosguild.apps.forum.models.post 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 post(scoremixin, profilemixin, models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/forum/models.py:119: removedindjango19warning: model class ankylosguild.apps.forum.models.commentpoint 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 commentpoint(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/forum/models.py:127: removedindjango19warning: model class ankylosguild.apps.forum.models.topicpoint 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 topicpoint(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/auctionhouse/models.py:10: removedindjango19warning: model class ankylosguild.apps.auctionhouse.models.auction 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 auction(models.model):  /users/neilhickman/sites/guild/ankylosguild/apps/auctionhouse/models.py:83: removedindjango19warning: model class ankylosguild.apps.auctionhouse.models.bid 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 bid(models.model): 

now poses 3 questions me.

  1. according documentation, options.app_label isn't requirement unless model outside of application module, in case, isn't. secondly, behaviour deprecated in 1.7 anyway, why issue?
  2. the applications in installed_apps tuple, surely can't that?
  3. why applications not loaded before called if in installed_apps tuple?

if indeed doing wrong, correct way of doing docs don't clear causing problem or how rectify it.

as stated in warning, happens either :

  • when you're using model not in installed_apps;
  • or when you're using model before application loaded.

since did refer app in installed_apps setting, you're using model before app initialisation.

typically, occurs when have from .models import somemodels in apps.py signal (for example post_migrate). instead of referring models classic way here, recommended use appconfig.get_model(). check apps.py file model import, , replace them using api.

for example instead of :

# apps.py  django.apps import appconfig .models import mymodel  def do_stuff(sender, **kwargs):     mymodel.objects.get() # etc...  class myappconfig(appconfig):     name = 'src.my_app_label'      def ready(self):         post_migrate.connect(do_stuff, sender=self) 

do :

# apps.py  django.apps import appconfig  def do_stuff(sender, **kwargs):     mymodel = sender.get_model('mymodel')     mymodel.objects.get() # etc...  class myappconfig(appconfig):     name = 'src.my_app_label'      def ready(self):         post_migrate.connect(do_stuff, sender=self) 

note enforcement introduced in bug #21719.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -