gpt4 book ai didi

python - Django:摆脱内容类型的 RemovedInDjango19Warning

转载 作者:太空宇宙 更新时间:2023-11-04 01:02:21 25 4
gpt4 key购买 nike

我想通过确保在 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'

关于python - Django:摆脱内容类型的 RemovedInDjango19Warning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32260264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com