show group categories in api
This commit is contained in:
parent
782666bcaf
commit
3762ebf37d
3 changed files with 13 additions and 7 deletions
|
@ -144,7 +144,10 @@ class SpecificLocation(Location, models.Model):
|
|||
def _serialize(self, detailed=True, **kwargs):
|
||||
result = super()._serialize(detailed=detailed, **kwargs)
|
||||
if detailed:
|
||||
result['groups'] = list(g.pk for g in self.groups.all())
|
||||
groups = {}
|
||||
for group in self.groups.all():
|
||||
groups.setdefault(group.category.name, []).append(group.pk)
|
||||
result['groups'] = groups
|
||||
return result
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue