form 传参数

form.py.  
class XXXForm(frms.Form):  
    a = Charfield()

    def __init__(self, user, *args, **kwargs):
        super(XXXForm, self).__init__(*args, **kwargs)
        self.user = user

views.py  
if request.method == "POST":  
    form = XXXForm(org_user, request.POST)

else:
    form = XXXForm(org_user)

你可能感兴趣的:(form 传参数)