I have 3 models in Django: Country, City, and Store.
When I create a new store in Django admin, I want to choose Country and City.
After I decide the Country, how can I make the options in City relate to the Country?
我在Django中有3个模型:Country,City和Store。当我在Django admin中创建一个新商店时,我想选择Country和City。在我决定国家之后,我如何让城市中的选项与国家相关?
Thank you so much!
非常感谢!
2 个解决方案
#1
1
What you need is Django Smart Selects. Also described here in this answer.
你需要的是Django Smart Selects。这个答案也在这里描述。
#1
1
What you need is Django Smart Selects. Also described here in this answer.
你需要的是Django Smart Selects。这个答案也在这里描述。
#2
0
Use ModelChoiceField