如何创建包含带下拉列表的表单的表单集?

时间:2012-10-11 09:40:27

标签: python django django-models

form.py

class ItemFSForm(Form):        
    item = forms.ModelChoiceField(required=False, queryset = '')

    def __init__(self, company, *args, **kwargs):
        super(ItemFSForm, self).__init__(*args, **kwargs)
        self.fields.sales_item.queryset = company.item_set.all()

formset_type = formset_factory(ItemFSForm, extra=0)

0 个答案:

没有答案