私は2つのモデルを持っています:
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
です。期待される動作ですか?
ps
Django 1.5.1を使用しています。