I have a form with an email field and email confirmation field. I want to check the form input to make sure the two fields match. So far I can get the error message 'Email addresses do not match.' to display, but if they do match I am getting an error 'InterfaceError at /order/ Error binding parameter 5 - probably unsupported type' Here is my code:
#models from django.db import models from django import forms from django.forms import ModelForm class Customer(models.Model): date_stamp = models.DateTimeField(auto_now_add=True) order_number = models.PositiveIntegerField(editable=False) first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=40) email = models.EmailField() email_conf = models.EmailField(verbose_name='Confirm Email') year_built = models.PositiveIntegerField() period = models.PositiveIntegerField(editable=False) direction = models.CharField(max_length=20, choices=direction_choices) floor_plan = models.CharField(max_length=2, choices=floor_plan_choices) def __unicode__(self): return u'%s %s' % (self.first_name, self.last_name) class CustomerForm(ModelForm): class Meta: model = Customer def clean_year_built(self): year = self.cleaned_data['year_built'] if year < 1800: raise forms.ValidationError("Please enter a year between 1800 and 2020.") if year > 2020: raise forms.ValidationError("Please enter a year between 1800 and 2020.") return year def clean_email_conf(self): cleaned_data = self.cleaned_data email = cleaned_data.get("email") email_conf = cleaned_data.get("email_conf") if email and email_conf: if email != email_conf: raise forms.ValidationError("Email addresses do not match.") return cleaned_data #views from django.shortcuts import render_to_response from django.http import HttpResponseRedirect from newsite.order.models import Customer, CustomerForm def order(request): if request.method == 'POST': form = CustomerForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/order_complete/') else: form = CustomerForm() return render_to_response('order.html', {'form': form}) def order_complete(request): return render_to_response('order_complete.html') -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.