Thanks a lot Mike, very nice help, you example helpe me with another
thing :) good!!!

now, when i said "key" (sorry!!) i want to say "some code like an
encryption key, and random number, etc".

im reading the django help and i cant find any topic about this part
(how make query than affect two or more tables)and in the same way
nothing about who get the last id.

I think that Django is very nice, but the documentation need more
details o maybe be more clear.

Thanks for u replay Mike :)

On Jul 29, 11:36 pm, mike <mkimm...@gmail.com> wrote:
> I'm not clear on what you mean by "key".  Foreignkey?  Or for
> instance, an encryption key stored in two tables?  I'm left to guess
> you mean a foreignkey.
>
> In this case, the second 'table' you refer to could have a foreignkey
> relating it back to the first table.  If this is what you mean,
> then ...
>
> Table 1: Child
>   - id: AutoField
>   - fn: CharField
>   - ln: CharField
>
> Table 2: Evaluation
>   - id: AutoField
>   - child: ForeignKey(Child)
>   - results: CharField
>
> Each would have a corresponding Form with all fields.
>
> Then in the request.POST processing...
>
> child_form = childForm(request.POST)
> eval_form = evalForm(request.POST)
>
> if child_form.is_valid() and eval_form.is_valid():
>     new_child = child_form.save()
>     eval_form = evalForm(request.POST, instance=new_child)
>     eval_form.save()
>
> Keep in mind, this always creates a new record in Child table, since
> the childForm was instantiated without an instance.  But that's
> different topic anyway.
>
> Also, if you need to access the pk of the new_child, you simply access
> it via new_child.pk
> i.e.
> new_child = child_form.save()
> new_pk = new_child.pk
>
> There is another way, but it depends a bit on the design of your
> models.
> hint: get object (if it exists) from second table, and update the
> corresponding fieldhttp://docs.djangoproject.com/en/1.0//topics/db/queries/
>
> Regards,
>
> Mike
--~--~---------~--~----~------------~-------~--~----~
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