This is a common problem to run into.

def form_valid(self, form): 

customer = form.save(commit=False)

customer.store = self.request.user.active_profile.store

customer.save() 

return super(CustomerInformationView, self).save(form)


super(CustomerInformationView, self).save(form)doesn't really make sense to 
do here for 2 reasons:

1. You just performed the model save manually the line above.
2. It's going to call save again except this time the form value for store 
is in fact Null (because it's blank in the form) and will raise the error.

So instead of calling super() - just return a httpresponse instead because 
that's really all you want in this case.
return HttpResponseRedirect(self.get_success_url())

(make sure you ahve the success url defined. Otherwise specify one.)

Also on your form you probably want to define it to exclude store - and if 
store is actually required you can probably leave off the blank=True.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to