Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GenericRelation Support #224

Closed
Closed
@snewcomer

Description

@snewcomer

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 theis not JSON serializable error. Guessing there might be some serialization issue with json api?

# Serializerclass FooSerializer(serializers.ModelSerializer):    included_serializers = {        'news': NewsSerializer,    }    class Meta:        model = Foo        fields = ('id', 'news')# News Serializerclass NewsSerializer(serializers.ModelSerializer):    class Meta:        model = News        fields = ('id', 'description', 'date')# Foo Modelclass FooModel(models.Model):    news = GenericRelation(News)# News Modelclass 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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp