Dnia 11-03-2011 o 21:23:38 greenie2600 <[email protected]> napisaƂ(a):

gontran -

Thanks.

However, I tried the sample code in your link, and I don't think it
will work. Returning a string from the overridden save() method
prevents the record from being saved to the database, but by the time
the save() method is invoked, my ModelForm (and consequently, I
presume, the underlying Model) has already been tested as valid. The
Restaurant isn't saved, but the form isn't redisplayed and no error
message is shown, and code execution proceeds as if the form were
valid (because it *is* valid; it just wasn't saved).

I think I need to override the model validation instead. Perhaps I
need to override Model.clean_fields()?


Right, i just get to that point, there is a cave rat about limiting choices on form level.
Depending on limiting query it may make problems if you edit this object.

afik U can't validate m2m fields on model level, but u can do it on form level and rise forms.ValidationError if needed in clean_field().

--
Linux user

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to