python - Django 1.9 弃用警告 app_label

标签 python django deprecation-warning

我刚刚更新到 Django v1.8,并在更新我的项目之前测试了我的本地设置,我收到了一个我以前从未见过的弃用警告,这对我来说也没有任何意义。我可能只是忽略了某些内容或误解了文档。

/Users/neilhickman/Sites/guild/ankylosguild/apps/raiding/models.py:6: RemovedInDjango19Warning: Model class ankylosguild.apps.raiding.models.Difficulty doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be 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 an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class Bid(models.Model):

现在这给我提出了 3 个问题。

  1. 根据documentation , Options.app_label 不是必需的,除非模型在应用程序模块之外,在我的情况下,它不是。其次,无论如何,这种行为在 1.7 中已被弃用,为什么它甚至是一个问题?
  2. 应用程序都在 INSTALLED_APPS 元组中,所以肯定不是这样吗?
  3. 如果所有内容都在 INSTALLED_APPS 元组中,为什么应用程序在调用之前不会被加载?

如果我确实做错了什么,那么正确的做法是什么,因为文档并没有真正弄清楚导致这个问题的原因或如何纠正它。

最佳答案

类似的错误。就我而言,错误是:

RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Site(models.Model):

我的解决方案是:

'django.contrib.sites' 添加到 INSTALLED_APPS

关于python - Django 1.9 弃用警告 app_label,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29635765/

相关文章:

python - scikit learn中的预处理-单个样本-折旧警告

python - DeprecationWarning - imp 模块

python - Django 模型不会保存

python - 使用发送方法pyzmq错误不支持检索操作

python - 为什么在这个列表推导中需要这个列表切片?

Django 在区分大小写的条目上不同

python - pymc3 中的后采样

python - Celery pickle type content disallowed 错误

python - Django 管理列表显示优化查询集

javascript - 我如何确定到底是什么原因导致了 Ember 弃用?