标签: chained-select

Django如何在Forms.py中进行链式选择?

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 …
Run Code Online (Sandbox Code Playgroud)

django django-forms django-views chained-select

4
推荐指数
1
解决办法
3537
查看次数