Tell me how to get all products from the parent category. I have categories
[& lt; category: men & gt; Clothing & GT;, & lt; Category: Men & GT; Clothing & GT; Shirts & gt;, & lt; Category: Men & GT; Clothing & GT; T-shirts & gt;, & lt; Category: Men & GT; Footwear & gt;, & lt; Category: Men & GT; Footwear & gt; Sneakers & gt;].
How can I get all the products of the category of men Queryset? and T-shirts and sneakers and TD
Answer 1, Authority 100%
First, get a list of all subfolded subcategories inside [& lt; Category: Men & GT;]
to the desired number of nestedness
For example
category_man_id = ... # Point the starting upper category
Sub1 = List (Category.Objects.Filter (Parent = Category_man_id))
sub2 = list (Category.Objects.Filter (Parent__in = Sub1))
# You can dial in the cycle the desired number of nested
Products = Product.Objects.Filter (Category__in = Sub1 + Sub2)