Friday, January 25, 2013

Again, Model and ModelForm validation

Hi everybody,

suppose I have a model and want to add some custom validation to *just
one* of its fields. Using Django 1.4 here.

I expect that specific validation constraint to be used both in my forms
and in my save method.

Should I better use Model clean_fields() method? Or the clean() one? Or
should I better rely on a custom ModelForm? Or, again, should I use a
custom save method?

In each case, how can I then propagate my ValidationError to the form so
that my specific field is highlighted in case the user inserts some
invalid data?

Any snippet or web reference is greatly appreciated.

Cheers, Fabio.

--
Fabio Natali

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate