Margie,

My best bet would be to override the model's save method and do your
validation there.

http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#overriding-default-model-methods

Ariel


On Wed, Jan 14, 2009 at 3:37 PM, Margie <margierogin...@yahoo.com> wrote:

>
> Supose I want to model the following: A Task is owned by a family but
> may additionally have specific owners that are within that family.
> The model would look like this:
>
> class Family(models.Model):
>   surName=models.CharField()
>
> class Task(models.Model):
>   ownerFamily=models.ForeignKey(Family)
>   owners = models.ManyToManyField(Person, blank=True, null=True)
>
> class Person(models.Model):
>   family = models.ForeignKey(Family)
>
> I want to enforce that the if a Task has owners, that each owner be in
> the Family specified by that task's ownerFamily.
>
> Could someone tell me where is the appropriate location in the code to
> enforce this?  I'm not sure if there is a way to enforce this within
> the model itself.  If not, then is the appropriate thing to do to just
> check it in my public interface when I, for example, add an owner to a
> task?
>
> Thanks!
>
> Margie
> Margie
> >
>

--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to