I am attempting to fetch nested objects but not quite sure how to achieve this. My model is as shown:
class Brand(models.Model)
name = models.CharField(max_length=128)
class Size(models.Model)
name = models.CharField(max_length=128)
class Brand_Size(models.Model)
brand = models.ForeignKey(Brand)
size = models.ForeignKey(Size)
class Brand_Size_Location(models.Model)
location = models.ForeignKey(Location)
brand_size = models.ForeignKey(Brand_Size)
I filter objects in Brand_Size_Location
by location which can occur 1..x
. I want my serializer to output the results in terms of the model Brand
(BrandSerializer). Since my resultset can be 1..x
and furthermore the occurrence of Brand
can be duplicates i would like to eliminate these aswell at the same time.