我正在制作一个应用程序,在用户注册后,他会参考一个页面,在该页面上他可以单击一个链接来填写另一个订单详细信息。当我单击该链接时,以下视图处于活动状态
def Checkout_Attributes(request):
check_form = Check_Attribute_Form()
context={'check_form':check_form}
return render_to_response('checkout.html',context,context_instance=RequestContext(request))
提交表单后,以下视图处于活动状态
def Set_Checkout_Attributes(request):
#if request.user.is_authenticated():
#return HttpResponseRedirect('/checkout/')
if request.method == 'POST':
check_form = Check_Attribute_Form(request.POST)
if check_form.is_valid():
customer_check=Customer_check_attributes(billing_add=check_form.cleaned_data['billing_add'],shipping_add=check_form['shipping_add'],payment_method=check_form['payment_method'],shipping_method=check_form['shipping_method'],reward_points=check_form['reward_points'])
customer_check.save()
return render_to_response('sucess.html')
else:
check_form=Check_Attribute_Form()
return render_to_response('a.html',{'check_form':check_form} , context_instance=RequestContext(request))
在这个视图中,我收到Set_Checkout_Attributes 的错误,没有返回 HttpResponse 对象。
还有一件事,当我提交空白表单时,它没有显示验证错误
模板是
<form action="/checkout1/" method="post">
{% csrf_token %}
{% if check_form.errors %}<h2>Please correct the following fields:</h2>{% endif %}
<div class="register_div">
{% if check_form.billing_add.errors %}<p class="error">{{ check_form.billing_add.errors }}</p>{% endif %}
<p><label for="billing_add" {% if check_form.billing_add.errors %} class="error"{% endif %}>Billing Address:</label></p>
<p>{{ check_form.billing_add }}</p>
</div>
.
.
.
.
.
<p><input type="submit" value="submit" aly="register"/></p>
</form>