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
class Event(models.Model):
title = models.CharField(max_length=151, db_index=True)
description = models.TextField(blank=True, null=True)
tags = TaggableManager()
serializers.py
class EventSerializer(serializers.ModelSerializer):
slug = serializers.SerializerMethodField()
tags = TagListSerializerField()
the Result I am having:
{
"id": 52,
"slug": "52-aperiam-amet",
"tags": [
"hello",
"world"
],
"title": "Aperiam amet",
"description": "Quibusdam ipsum sun Quibusdam ipsum sun Quibusdam ipsum sun ",
},
The text was updated successfully, but these errors were encountered:
MicroDreamIT
changed the title
Wish to have more detail in serializer
Wish to have more detail in serializer, looking for tags should be nested with all the items
Jun 19, 2023
I'm not going to outright close this because it might make sense to have some extra serializers, but we can't change the existing one.
I think it makes sense to have both, because in many use cases you don't want to expose the tag ID.
Let's keep this open and maybe we can have someone contribute a more detailed serializer for those who want it 👍 At the very least we can write a very small doc guide to just point out how to easily do this with DRF
Have a DetailedTaggedItemSerializer that could render out a TaggedItem as {name: "foo bar", slug: "foo_bar", id: 1}
Have a DetailedTagListField that would probably just be a ListField that uses DetailedTaggedItemSerializer in the child
have some test cases involving canonical API interactions (maybe we just implement read-only stuff for now and not. try to resolve create/update first? I dunno)
here is my Model is look like
model.py
serializers.py
the Result I am having:
but expected tags nest should look like
The text was updated successfully, but these errors were encountered: