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)
相關文章
相關標籤/搜索