Hi,

you can overload the save method of Model1 in a way
that it checks type and if it is machine, create two record in Model2.

-- 
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: ilian.i-n-i.org

On Thu, Dec 9, 2010 at 11:21 PM, Nick <nickt...@gmail.com> wrote:

> I am working on a project in which I need to evaluate a field in one
> model and based on its values add entries to another model. I don't
> quite now how to succinctly put that into words which is why searching
> for a solution has been so annoying.
>
> Here is my example
>
> Type_Choices = (
>    ('Person', 'Person'),
>    ('Machine', 'Machine'),
>    )
>
> class Model1(models.Model):
>    type = models.CharField(max_length=100, choices=Type_Choices)
>    name = models.CharField(max_length=100)
>
> class Model2(models.Model):
>    person_job = models.CharField()
>    machine_job = models.CharField()
>
>
> what I'd like to do is evaluate type on Model 1 when and entry is
> first created and then if it evaluates to Machine create two new
> entries in Model2. One for  machine_job = primary and one for
> machine_job = secondary. I only want this to fire on the initial save
> of the Model1 object.
>
> Any help with actual code examples or ways of phrasing this so as not
> to confuse google is appreciated.
>
> --
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to