Django:摆脱了removedInDjango19Warning for contenttypes

时间:2015-08-27 22:10:12

标签: python django

我想摆脱这个警告"对"通过确保我准备好在它到达时更新到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删除它时(不确定我真的应该这样做!),我得到了一个不同的弃用警告:

/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):

对我来说,做什么是正确的?

1 个答案:

答案 0 :(得分:3)

看起来该消息告诉您问题来自应用程序South,而不是您的代码库。

通常,防止弃用错误的正确方法是将应用程序升级到已修复问题的版本。有时,如果尚未发布新版本,则可能无法实现。

然而,在这种情况下,我不知道你为什么要安装南方。对于Django 1.7+,您应该使用Django的内置迁移。您是否尝试从已安装的应用中删除'south'