GenericForeignKey
是否可以在 Django 管理员中按对象标题进行过滤?
我想按程序名称过滤,NonSupportedProgram.title
或者SupportedProgram.title
(list_filter = (SOME FIELD HERE)
),但不知道怎么做?
模型.py
class FullCitation(models.Model):
# the software to which this citation belongs
# either a supported software program or a non-supported software program
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
class NonSupportedProgram(models.Model):
title = models.CharField(max_length=256, blank = True)
full_citation = generic.GenericRelation('FullCitation')
class SupportedProgram(models.Model):
title = models.CharField(max_length=256, blank = True)
full_citation = generic.GenericRelation('FullCitation')