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 Rowling,则必须在书籍选择字段中填写哈利波特系列(1 到 4 个选项)
如果用户选择作者为 Agatha Christie 则只有 (5 到 8 ) 必须填写在书籍选择字段中
如果用户选择 Author As Mark Twain 那么只有(8 到 11)选项必须填充在书籍选择字段的选择小部件中
我想过滤选择有人可以帮忙吗?