我有两个模型:
class First(models.Model):
name = models.CharField(max_length=50, default='n/a')
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
def __unicode__(self):
return str(self.pk) + ' > ' + self.name
class Second(models.Model):
name = models.CharField(max_length=50, default='n/a')
r = generic.GenericRelation(First)
def __unicode__(self):
return str(self.pk) + ' > ' + self.name
当我做:
from myapp.models import First
First._meta.get_all_field_names()
我得到:
['content_type', u'id', 'name', 'object_id', 'second']
因此,似乎而不是content_object,GenericForeignKey命名为second。这是预期的行为吗?
慕虎7371278
相关分类