I have two models Categories and Products. A Product can have multiple Categories, a Category can have multiple Products.
The Categories have a circular Foreign key, to itself. class Product: categories = models.ManyToManyField(Category) name = models.CharField(max_length=255) class Category: categories = models.ManyToManyField(Category) name = models.CharField(max_length=255) Not all Categories have the same depth level. A Category can have no children and a Category can have multiple grandchildren. *What I want to achieve:* When a user add/create a Product, only a select-box containing the parents will appear. After the parent is selected, if the parent has children another select will appear with that parent children. Also the possibility to add more categories. When a user what to edit a product the select boxes for what was already chosen should be available. *From where I start:* I know that to ManyToMany relation corresponds a ModelMultipleChoiceField Field. To a ModelMultipleChoiceField corresponds a SelectMultiple widget. I thought of creating an widget that inherits from SelectMultiple and change the templates manipulating the get_context_data on the Widget. But my problem is that in context I don't have (know to find) the parent relation inside categories. What are my options ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7a0c5ab1-8297-41f4-befa-3d0063f100d2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.