禰獲得初始值也是一個選項做到這一點的看法.....
老式方法....
但是,這不是一個模型的形式...
所以艾丹的回答是好,但如果你真的想要做自定義的東西...老式的方式
if request.method == 'POST': # If the form has been submitted...
form = TestForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
whatever = form.cleaned_data['whatever']
#and you can update the data and make the form with the new data
data = {'whatever': whatever,'etc.': etc}
form=TestForm(data)
else:
# An unbound form
form = TestForm(initial={'whatever': whatever,'etc.': etc})
return render_to_response(template,{'form':forms},context_instance=RequestContext(request))