>(the save() method shouldn't raise
>any validation errors except those triggered by the database server due
>to IntegrityErrors).

So what is the recommended place to write validations in models, for
now?

On Feb 22, 12:25 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-02-21 at 08:54 -0800,shabdawrote:
> > I have some models, and some forms to write data to them. The
> > attributes in models need to have soem validations, (For example, name
> > must be alpha numeric, price must be less that 1000 etc). SO I write
> > the validations in model.save() and raise Exceptions, when a
> > validation fails. I also need to write the same validations in
> > newforms as I do not want the form post to happen unless the
> > validation passes. This means that I have the same validation at two
> > places. (I can't raise ValidationException from models).  Is there a
> > way to remove this duplication?
>
> Some current work-in-progress is model-aware validation. This will
> provide a validate() method on models (the save() method shouldn't raise
> any validation errors except those triggered by the database server due
> to IntegrityErrors). At the same time, this means forms created directly
> from models will use the models' validation functions to validate the
> fields. Finally, the validation functions will be able to be used mostly
> identically for form fields and model fields.
>
> So, it's coming. Just wait a little longer.
>
> Malcolm
>
> --
> Always try to be modest and be proud of it!http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to