Hello-

I was wondering if it would be reasonable to modify the 
`django.views.generic.edit.ProcessFormView` class, such that the `post()` 
function calls a (hypothetical) `self.validate_form(form)` function rather 
than directly calling `form.is_valid()`. The default implementation of 
`validate_form()` would of course be to call `form.is_valid()`, to maintain 
backwards compatibility.

Background:

I am writing an application where a model (I'll call it `Thing`) has a 
ForeignKey to User and a CharField ("name"), among some other fields. I 
would like "name" to be unique for any given user; I'm using 
`unique_together` in `class Meta:` to accomplish this. I have a CreateView 
subclass which allows users to create new Things; the `user` field is 
excluded from the form, and automatically set in the View. I was previously 
doing this in the `form_valid` function, but realized that this is being 
called after the form is already validated (without a User). By the time 
the object is saved to the database, the `user

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/e3f3b996-94b2-4dd2-87df-dab6947827f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to