Closed yarnball closed 7 years ago
Got it- fixed by doing
tag = instance.tag.all()
So my full result:
class MyModelEsSerializer(EsJsonSerializer):
def serialize_tag(self, instance, field_name):
tag = instance.tag.all()
grouped_tags = {
tag_level: [
{ 'name': tag_of_level.name, 'taglevel': tag_of_level.taglevel, }
for tag_of_level in tags_of_level
] for tag_level, tags_of_level
in groupby(tag, lambda tag: tag.taglevel)
}
return grouped_tags
Hi,
Nice work on this repo.
I am trying to implement a function to modify my data called
get_grouped_tags
.However, I keep getting an error
'QuerySet' object has no attribute 'tag'
.How do I handle M2M's on your serializer? Thanks
myapp/models.py
myapp/elastic/serializers.py