我想通过确保在 Django 1.9 到达时准备好更新到它来以“正确”的方式摆脱这个警告。
我收到的弃用警告如下:
/Users/.../south/modelsinspector.py:20: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
from django.contrib.contenttypes import generic
我已经在我的项目中完整搜索了短语 django.contrib.contenttypes,我唯一能找到它的地方是 INSTALLED_APPS。
但是,当我从 INSTALLED_APPS 中删除它时(不确定我是否真的应该这样做!),我得到了一个不同的 DeprecationWarning:
/Users/.../django/contrib/contenttypes/models.py:159: RemovedInDjango19Warning: Model class django.contrib.contenttypes.models.ContentType 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 ContentType(models.Model):
我应该做什么?
请您参考如下方法:
消息似乎是在告诉您问题出在应用程序 South,而不是您的代码库。
通常,防止弃用错误的正确方法是将应用升级到已修复问题的版本。有时,如果尚未发布新版本,这可能是不可能的。
但是,在这种情况下,我完全不知道您为什么要安装 South。对于 Django 1.7+,您应该使用 Django 的内置迁移。您是否尝试过从已安装的应用程序中删除 'south'?
