2
class Library(forms.ModelForm):
author = forms.ChoiceField(
widget = forms.Select(),
choices = ([
('Jk Rowling','Jk Rowling'),
('agatha christie','agatha christie'),
('mark twain','mark twain'),
]),
initial = '1',
required = True,
)
books = forms.ChoiceField(
widget = forms.Select(),
choices = ([
('Harry Potter 1','Harry Potter 1'), # 1
('Harry Potter 2','Harry Potter 2'), # 2
('Harry Potter 3','Harry Potter 3'), # 3
('Harry Potter 4','Harry Potter 4'), # 4
('The A.B.C. Murders','The A.B.C. Murders'), # 5
('Dumb Witness','Dumb Witness'), # 6
('Death on the Nile','Death on the Nile'), # 7
('Murder Is Easy','Murder Is Easy'), # 8
('Roughing It','Roughing It'), # 9
(' The Gilded Age ',' The Gilded Age '), # 10
('Adventures of Tom Sawyer','Adventures of Tom Sawyer'), # 11
]),
initial = '1',
required = True,
)
如果用户选择了作者作为JK罗琳的哈利·波特系列必须在书籍的选择字段来填充(1至4选择)如何做Django链接在Forms.py中选择?
如果用户选择了作者作为阿加莎·克里斯蒂那么只有(5〜8 )必须在书籍的选择现场
填充如果用户选择作者正如马克吐温然后只(8〜11)选择必须在书籍的选择字段的选择控件来填充
我想过滤这些选择可以帮助吗?
[如何在使用Modelform和jquery的django中获得互相依赖的下拉列表?](http://stackoverflow.com/questions/14121132/how-to-get-interdependent-dropdowns-in-django-using-modelform - 和 - jquery) – e4c5