Django: Transform an object into an object of a derived model class
In Django I've got a model class M1 and class M2 which is derived of M1.
In the database this is generated as two tables T1 and T2 where T2 points to T1 like this:
T1.id = T2.T1_ptr_id
So far so good.
Now it might be that in the database the entry for for T2 is missing sometimes - and I would like to create this entry on the fly by changing M1 to M2 in Django.
I have tried this, but it (obviously) fails:
m2 = M2(pk=m1.id)
Furthermore I don't want to create a new instance of M2 - i want to transform M1 into M2. Is there a way to do this?