If you look here http://docs.djangoproject.com/en/dev/topics/db/models/#id7
you'll see that multi-table inheritance is handled at the db level
"via an automatically-created OneToOneField". This means that an
instance of B has a foreign key to an instance of A.

At the model level, there should be an a_ptr and an a_ptr_id
attributes (check with a dir(b) for example). The first one is the
instance of A associated with b, and the second the id of that
instance of A. So, I imagine that:
b = B()
b.a_ptr = a
b.save()

or

b = B()
b.a_ptr_id = a_id
b.save()

should do what you want.

Rodrigue
On Jul 20, 4:03 pm, Peter Cicman <pcic...@gmail.com> wrote:
> Hi, i didn't found noting about it in docs, so i'll try to ask, first
> explanation, i have:
>
> class A(models.Model):
>     name = models.CharFiled(...., required=True)
>     .....
>
> class B(A):
>     ....
>
> I have an existing instance of A, say `a`
>
> and i "want to make" instance of b out of it.
>
> i'm looking for something like:
>     b = B()
>     b.origin = a
>     b.save()
>
> Is this somehow possible?
>
> Thanks a lot!
--~--~---------~--~----~------------~-------~--~----~
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