jazzband / django-smart-selects

chained and grouped selects for django forms
https://django-smart-selects.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.12k stars 352 forks source link

how to use smart-selects for a many to many field against a foreign key selection in django admin? #329

Open skalluri01 opened 3 years ago

skalluri01 commented 3 years ago

In the below scenario, how to display the subcategories of the selected category only in admin site? Chained ForeignKey/ Chained Many to Many doesn't provide such use case..

class Category(models.Model): name = models.CharField(max_length=20)

class SubCategory(models.Model): name = models.CharField(max_length=20) category= models.ForeignKey(Category)

class Course(models.Model): name = models.CharField(max_length=20) category= models.ForeignKey(Category) subcategory=models.ManytoManyField(SubCategory)