相关字段的查找无效:名称 content_type__name
Related Field got invalid lookup: name with content_type__name
我有以下...
@receiver(post_save)
def po_save(sender, instance, created, **kwargs):
Event.objects.get(content_type__name=sender.__name__)
给出错误:相关字段查找无效:名称。
content_type__name
似乎有问题,但是我使用 content_type name
我做错了什么?
来自 Django 1.8 的 release notes:
The name field of django.contrib.contenttypes.models.ContentType has
been removed by a migration and replaced by a property. That means
it’s not possible to query or filter a ContentType by this field any
longer.
我有以下...
@receiver(post_save)
def po_save(sender, instance, created, **kwargs):
Event.objects.get(content_type__name=sender.__name__)
给出错误:相关字段查找无效:名称。
content_type__name
似乎有问题,但是我使用 content_type name
我做错了什么?
来自 Django 1.8 的 release notes:
The name field of django.contrib.contenttypes.models.ContentType has been removed by a migration and replaced by a property. That means it’s not possible to query or filter a ContentType by this field any longer.