This project is being developed in python and django.
As per my requirement I want to querying all the products from the categories upto two to three level up...
My entity structure is as follows.
Category:
- Name
- ParentCategory
Product:
- ID
- Name
- Category
Here are sample records which I want to query.
Category:
- Name: Apparel | Parent:None
- Name: Shirt | Parent: Apparel
- Name: TShirts | Parent: Apparel
- Name: MaleTShirts | Parent:TShirts
- Name: FemaleTShirts | Parent: TShirts
- Name:Electornics | Parent:None
Product:
- ID:1 | Name:ABC | Category:MaleTShirt
- ID:2 | Name:XYZ | Category:FemaleTShirt
- ID:3 | Name:JKL | Category:Shirt
Problem is, user should access these products from any level in category. For example,
- When user selects category Apparel, product ABC, XYZ, and JKL should appear in the resultset.
- When user selects category TShirts, product ABC and XYZ should appear in the resultset.
- When user selects category MaleTShirts, only ABC should appear in the resultset.
- When user selects category FemaleTShirts, only XYZ should appear in the resultset.
Any idea how the model classes should be structured, and how should we query so that desired results can be achieved.
Any suggestions would be helpful. It would be good if code is also provided.