I am using a Generic Relation on a model and trying to serialize it using Django Rest Framework. However doing the following gives me an attribute error :
'GenericForeignKey' object has no attribute 'field'
models.py
class AdditionalInfo():
#other fields
seal_type = models.ForeignKey(ContentType,
related_name='seal'
)
seal_id = models.PositiveIntegerField(null=True)
seal = generic.GenericForeignKey(
'seal_type',
'seal_id')
serializers.py
class AdditionalInfoSerializer():
seal = serializers.Field(source='seal')
What am I doing wrong? I wasn't able to find much about this in the django rest framework documentation.