Django drf Serialize group by model field

Django drf Serialize group by model field
I have drf endpoint i get this result, but i want to group this result by model field product_type, how i can implement this? i tryed like in this answer DRF: Serializer Group By Model Field
but it didn’t help me

[
    {
        "id": 1,
        "name": "Danwich ham and cheese",
        "product_type": "Snacks",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FF0059B799A17F57A9E64C725.avif",
        "grams": 210,
        "description": "Crispy ciabatta and the familiar combination of ham, chicken, mozzarella with fresh tomatoes, ranch sauce and garlic",
        "extra_info": "",
        "price": "3.28",
        "extra_ingredients": []
    },
    {
        "id": 2,
        "name": "Danwich Chorizo ​​BBQ",
        "product_type": "Snacks",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FF041FE1F94C903576DCFD01E.avif",
        "grams": 210,
        "description": "Rich taste of spicy chorizo ​​sausages and spicy pepperoni with burger and barbecue sauces, fresh tomatoes, pickled cucumbers, mozzarella and onions in a golden ciabatta",
        "extra_info": "",
        "price": "3.28",
        "extra_ingredients": []
    },
    {
        "id": 3,
        "name": "Chocolate milkshake",
        "product_type": "Cocktails",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FA24D1E919FA050D8BA21F8E9.avif",
        "grams": null,
        "description": "Charming chocolate delicacy. Try a milkshake with cocoa and ice cream",
        "extra_info": "0.3 L",
        "price": "2.71",
        "extra_ingredients": []
    },
    {
        "id": 4,
        "name": "Strawberry milkshake",
        "product_type": "Cocktails",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FB231A5BF82B0A99A1B12339C.avif",
        "grams": null,
        "description": "No matter what time of year it is, this cocktail with strawberry concentrate will take you back to summer in one sip.",
        "extra_info": "0.3 L",
        "price": "2.71",
        "extra_ingredients": []
    },
    {
        "id": 5,
        "name": "Coffee Americano",
        "product_type": "Cofe",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61B044583596548A59078BBD33.avif",
        "grams": null,
        "description": "A couple of sips of hot Americano and you'll be ready to conquer the day.",
        "extra_info": "0.4 L",
        "price": "1.28",
        "extra_ingredients": []
    },
    {
        "id": 6,
        "name": "Coffee Cappuccino",
        "product_type": "Cofe",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61AE1813B4AB42D8927D061035.avif",
        "grams": null,
        "description": "The king among coffee drinks is the classic cappuccino. For lovers of balanced coffee and milk taste",
        "extra_info": "0.4 L",
        "price": "1.87",
        "extra_ingredients": []
    },
    {
        "id": 7,
        "name": "Orange juice Rich",
        "product_type": "Beverages",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61B223E75EB71498BCAA0D4A0D.avif",
        "grams": null,
        "description": "",
        "extra_info": "1 L",
        "price": "3.05",
        "extra_ingredients": []
    },
    {
        "id": 8,
        "name": "Apple juice Rich",
        "product_type": "Beverages",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61B27F1652B9A918BDDD753D8D.avif",
        "grams": null,
        "description": "",
        "extra_info": "1 L",
        "price": "3.05",
        "extra_ingredients": []
    },
    {
        "id": 9,
        "name": "Cheesecake New York",
        "product_type": "Desserts",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EEE20B6B6EC471AB74AB8F8885775B.avif",
        "grams": null,
        "description": "We tried a thousand desserts and finally found the guests' favorite - the most delicate curd cheesecake",
        "extra_info": "1 psc. 100 grams",
        "price": "2.11",
        "extra_ingredients": []
    },
    {
        "id": 10,
        "name": "Banana cheesecake with chocolate cookies",
        "product_type": "Desserts",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE797014D8F94683D580455892ABA1.avif",
        "grams": 100,
        "description": "Sunny on the outside and bright in taste on the inside. Summer novelty - delicate cheesecake with banana and chocolate cookies",
        "extra_info": "",
        "price": "1.87",
        "extra_ingredients": []
    },
    {
        "id": 11,
        "name": "BBQ",
        "product_type": "Sauces",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EEE205E4AFB158AFCB34392A1F6FC1.avif",
        "grams": 25,
        "description": "Branded sauce with a smoky aroma for pizza sides and hot appetizers, 25 g",
        "extra_info": "1 psc",
        "price": "0.53",
        "extra_ingredients": []
    },
    {
        "id": 12,
        "name": "Garlic Sause",
        "product_type": "Sauces",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE79700EBD09E7A7603B26879BC7B0.avif",
        "grams": 25,
        "description": "Branded sauce with garlic flavor for pizza sides and hot appetizers, 25 g",
        "extra_info": "1 psc",
        "price": "0.53",
        "extra_ingredients": []
    }
]

how i can group by product_type in something like this

{
    "Snacks": [
      {
        "id": 1,
        "name": "Danwich ham and cheese",
        "product_type": "Snacks",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FF0059B799A17F57A9E64C725.avif",
        "grams": 210,
        "description": "Crispy ciabatta and the familiar combination of ham, chicken, mozzarella with fresh tomatoes, ranch sauce and garlic",
        "extra_info": "",
        "price": "3.28",
        "extra_ingredients": []
    },
    {
        "id": 2,
        "name": "Danwich Chorizo ​​BBQ",
        "product_type": "Snacks",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FF041FE1F94C903576DCFD01E.avif",
        "grams": 210,
        "description": "Rich taste of spicy chorizo ​​sausages and spicy pepperoni with burger and barbecue sauces, fresh tomatoes, pickled cucumbers, mozzarella and onions in a golden ciabatta",
        "extra_info": "",
        "price": "3.28",
        "extra_ingredients": []
    }
    ],
    "Cocktails": [
      {
        "id": 3,
        "name": "Chocolate milkshake",
        "product_type": "Cocktails",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FA24D1E919FA050D8BA21F8E9.avif",
        "grams": null,
        "description": "Charming chocolate delicacy. Try a milkshake with cocoa and ice cream",
        "extra_info": "0.3 L",
        "price": "2.71",
        "extra_ingredients": []
    },
    {
        "id": 4,
        "name": "Strawberry milkshake",
        "product_type": "Cocktails",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE796FB231A5BF82B0A99A1B12339C.avif",
        "grams": null,
        "description": "No matter what time of year it is, this cocktail with strawberry concentrate will take you back to summer in one sip.",
        "extra_info": "0.3 L",
        "price": "2.71",
        "extra_ingredients": []
    }
    ],
    "Cofe": [
      {
        "id": 5,
        "name": "Coffee Americano",
        "product_type": "Cofe",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61B044583596548A59078BBD33.avif",
        "grams": null,
        "description": "A couple of sips of hot Americano and you'll be ready to conquer the day.",
        "extra_info": "0.4 L",
        "price": "1.28",
        "extra_ingredients": []
    },
    {
        "id": 6,
        "name": "Coffee Cappuccino",
        "product_type": "Cofe",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61AE1813B4AB42D8927D061035.avif",
        "grams": null,
        "description": "The king among coffee drinks is the classic cappuccino. For lovers of balanced coffee and milk taste",
        "extra_info": "0.4 L",
        "price": "1.87",
        "extra_ingredients": []
    }
    ],
    "Beverages": [
      {
        "id": 7,
        "name": "Orange juice Rich",
        "product_type": "Beverages",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61B223E75EB71498BCAA0D4A0D.avif",
        "grams": null,
        "description": "",
        "extra_info": "1 L",
        "price": "3.05",
        "extra_ingredients": []
    },
    {
        "id": 8,
        "name": "Apple juice Rich",
        "product_type": "Beverages",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE7D61B27F1652B9A918BDDD753D8D.avif",
        "grams": null,
        "description": "",
        "extra_info": "1 L",
        "price": "3.05",
        "extra_ingredients": []
    }
    ],
    "Deserts": [
      {
        "id": 9,
        "name": "Cheesecake New York",
        "product_type": "Desserts",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EEE20B6B6EC471AB74AB8F8885775B.avif",
        "grams": null,
        "description": "We tried a thousand desserts and finally found the guests' favorite - the most delicate curd cheesecake",
        "extra_info": "1 psc. 100 grams",
        "price": "2.11",
        "extra_ingredients": []
    },
    {
        "id": 10,
        "name": "Banana cheesecake with chocolate cookies",
        "product_type": "Desserts",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE797014D8F94683D580455892ABA1.avif",
        "grams": 100,
        "description": "Sunny on the outside and bright in taste on the inside. Summer novelty - delicate cheesecake with banana and chocolate cookies",
        "extra_info": "",
        "price": "1.87",
        "extra_ingredients": []
    }
    ],
    "Sauces": [
      {
        "id": 11,
        "name": "BBQ",
        "product_type": "Sauces",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EEE205E4AFB158AFCB34392A1F6FC1.avif",
        "grams": 25,
        "description": "Branded sauce with a smoky aroma for pizza sides and hot appetizers, 25 g",
        "extra_info": "1 psc",
        "price": "0.53",
        "extra_ingredients": []
    },
    {
        "id": 12,
        "name": "Garlic Sause",
        "product_type": "Sauces",
        "img_url": "https://media.dodostatic.net/image/r:292x292/11EE79700EBD09E7A7603B26879BC7B0.avif",
        "grams": 25,
        "description": "Branded sauce with garlic flavor for pizza sides and hot appetizers, 25 g",
        "extra_info": "1 psc",
        "price": "0.53",
        "extra_ingredients": []
    }
    ]
}

my code

.models.py

class Product(models.Model):

    PRODUCT_TYPE_CHOICES = [
        ('Snacks', 'Snacks'),
        ('Beverages', 'Beverages'),
        ('Cocktails', 'Cocktails'),
        ('Cofe', 'Cofe'),
        ('Desserts', 'Desserts'),
        ('Sauces', 'Sauces'),
    ]


    name = models.CharField(max_length=50)
    product_type = models.CharField(max_length=50, choices=PRODUCT_TYPE_CHOICES)
    img_url = models.URLField()
    grams = models.PositiveSmallIntegerField(blank=True, null=True)
    description = models.TextField(max_length=500, blank=True)
    extra_ingredients = models.ManyToManyField(Extra_Ingredients, blank=True)
    extra_info = models.CharField(max_length=50, blank=True)
    price = models.DecimalField(max_digits=5, decimal_places=2)

    def __str__(self) -> str:
        return f'{self.product_type}'

.serialers.py

class ProductSerializer(serializers.ModelSerializer):
    class Meta:
        model = Product
        fields = '__all__'


.view.py

class ProductGroupApiView(generics.ListAPIView):
    queryset = Product.objects.all()
    serializer_class = ProductSerializer

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật