使用django-polymorphic时RemovedInDjango19Warning

时间:2015-06-25 13:24:17

标签: django

我开始在我的项目中使用django-polymorphic,它基于Django 1.8.1。

它工作正常,但我收到以下警告:

env/lib/python2.7/site-packages/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):

我像这样插入了Polymorphic:

INSTALLED_APPS = (
    'polymorphic',
    'django.contrib.contenttypes',
    ...
    'myapp1',
    'myapp2',
)

在myapp1 / models.py中我有我的基本模型:

class MyBaseModel(PolymorphicModel):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4)
    # some other fields

在myapp2 / models.py中我有我的派生模型:

from myapp1.models import MyBaseModel


class MyDerivedModel1(MyBaseModel):
    # some fields


class MyDerivedModel2(MyBaseModel):
    # some other fields

我做错了吗?

1 个答案:

答案 0 :(得分:2)

您似乎需要在polymorphic之后将contenttypes放入已安装的应用列表中。