Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter a dropdownlist in Django's admin when a selection is made on another dropdownlist

I have two dropdownlists in a Django admin site. For example, I have SelectCountry and SelectRegion. Region has a foreignkey relationship to Country. How do I ensure that when a Country is selected, the Regions are filtered based on that Country?

N.B: I am using django-grappelli for my admin backend as well.

Any ideas will be appreciated. Thanks.

like image 896
S. Dube Avatar asked Mar 24 '12 16:03

S. Dube


1 Answers

As DrMeers hints at, use django-smart-selects. No point in re-inventing the wheel.

like image 117
dan-klasson Avatar answered Oct 31 '22 11:10

dan-klasson