You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is GenericRelation support possible? This is how I would do it with Django rest. Can't get this to work however as I am getting the is not JSON serializable error. Guessing there might be some serialization issue with json api?
# Serializer
class FooSerializer(serializers.ModelSerializer):
included_serializers = {
'news': NewsSerializer,
}
class Meta:
model = Foo
fields = ('id', 'news')
# News Serializer
class NewsSerializer(serializers.ModelSerializer):
class Meta:
model = News
fields = ('id', 'description', 'date')
# Foo Model
class FooModel(models.Model):
news = GenericRelation(News)
# News Model
class News(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
description = models.TextField(max_length=200, blank=True)
date = models.DateTimeField(blank=True, null=True)
content_type = models.ForeignKey(ContentType)
object_id = models.UUIDField()
content_object = GenericForeignKey('content_type', 'object_id')
class JSONAPIMeta:
resource_name = 'news'
I'd be happy to add some "documentation" through the examples and work through it that way. That is of course if somebody has not already come across this!
The text was updated successfully, but these errors were encountered:
Is GenericRelation support possible? This is how I would do it with Django rest. Can't get this to work however as I am getting the
is not JSON serializable
error. Guessing there might be some serialization issue with json api?I'd be happy to add some "documentation" through the examples and work through it that way. That is of course if somebody has not already come across this!
The text was updated successfully, but these errors were encountered: