我有一个模式:
class Customer(models.Model):
name = models.CharField(max_length=200)
email = models.EmailField()
company = models.CharField(max_length=100, blank=True)
breakfast = models.BooleanField(blank=True)
dinner = models.BooleanField(blank=True)
training = models.BooleanField(blank=True)
joined = models.DateTimeField(auto_now_add=True)
观点:
def cust_form(request):
if request.method == POST :
form = CustForm(request.POST)
form_type = Customer
if form.is_valid():
email = request.POST[ email ]
name = request.POST[ name ]
if request.POST[ training ] == True:
mail.mailsend(name, email, cus_type= train )
else:
mail.mailsend(name, email, cus_type= stand )
form.save()
return Redirect( /cr/ )
return render_to_response( cust_form.html ,
{ form : form,
form_type : form_type},
context_instance=RequestContext(request))
如果他们选择了培训,我想发出一个电子邮件,如果他们没有的话。 然而,如果无线电箱没有受到控制,我就有一个<代码>。 MultiValueDictKeyError at /Customer/
是的/否,是解决这一外国问题的唯一办法吗?