Невозможно получить .save () для записи в БД
Это модель
class Customer(models.Model):
email = models.EmailField()
postcode = models.CharField(max_length=10)
def __unicode__(self):
return self.email
def save(self):
self.postcode=upper(self.postcode)
super(Customer, self).save()
Это вид:
class RegisterForm(ModelForm):
class Meta:
model = Customer
def register(request):
form = RegisterForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
postcode = form.cleaned_data['postcode']
postcode = upper(postcode)
try:
user = Customer.objects.all().filter(email=email).filter(postcode=postcode)[:1]
if user:
error = "You have already registered this email address and postcode, please login."
return render_to_response("customer/register_form.html", {'error': error, 'form': form, 'content': content,},context_instance=RequestContext(request))
except Customer.DoesNotExist:
cust_obj = Customer(email=email, postcode=postcode)
cust_obj.save()
return HttpResponseRedirect('/registration-thankyou/')
Такжепробовал
new_user = form.save(commit=False)
new_user.save()
Он не выдает никаких ошибок, просто не сохраняет в таблице Приветствия для любого понимания / помощи