Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Model validation (not form validation) [RSS Feed]

#1 June 16, 2010 08:10:43

M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model validation (not form validation)


Hi,
I'm making a model, that has a bit complex dependencies between the fields,
such as date progression (start_date must not be later than finish_date).
I'm looking for a way to validate these dependencies while creating (or
saving) the model, but I am not sure which approach should I use.

The best solution would be overriding Model's method *clean*, but this seems
to work only when working with forms. Another solution utilizes pre_save()
or save() methods.

Which one is the "proper" one?

Regards,
Mateusz Haligowski

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

Offline

#2 June 17, 2010 08:52:46

d.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Model validation (not form validation)


On Jun 16, 8:20 am, MH <mhaligow...@googlemail.com> wrote:
> Hi,
> I'm making a model, that has a bit complex dependencies between the fields,
> such as date progression (start_date must not be later than finish_date).
> I'm looking for a way to validate these dependencies while creating (or
> saving) the model, but I am not sure which approach should I use.
>
> The best solution would be overriding Model's method *clean*, but this seems
> to work only when working with forms. Another solution utilizes pre_save()
> or save() methods.
>
> Which one is the "proper" one?
>
> Regards,
> Mateusz Haligowski

There's a good example at:http://www.jroller.com/RickHigh/entry/django_admin_and_field_validation--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Model validation (not form validation) [RSS Feed]

Board footer

Moderator control

Enjoy the 20th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support