django form表格,数据实时更新

class TestForm(forms.Form):
    price = fields.IntegerField()
    user_id = fields.IntegerField(
        # widget = widgets.Select(choices=[(0,'1111'),(1,'222222')])
        widget = widgets.Select()
    )

    def __init__(self,*args,**kwargs):
        super(TestForm.self).__init__(*args,**kwargs)

        self.fields['user_id'].widget.choices =             models.UserInfo.objects.values_list('id','username')

 

你可能感兴趣的:(python)