you could have a field "parent" in your Model Category which is a ForeignKey to Category itself, so Category is a self-referencing table.
Then in your first dropdown you only show those entries where parent is None and in your second one where parent == accessories.
you need to get this right with your view which would be show_child_categories where you pass the id of your parent and filter for it in your view function.
hope that helps, antje
On 5/17/20 11:21 PM, saqlain abbas wrote:
Hi, if i add Categories , for example--1)accessories2)sports3)booksSubcategories:accessories is the parent categorychild categories arewatchesjewlrycapshow can i show if user selects the parent category accessories then the subcategories show according to parent categories like subcategories are watches jewlry etc
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1530c511-072f-44ee-83fa-3555bd090a89%40googlegroups.com.
No comments:
Post a Comment