Inheriting a Django Model - Can I Change the Model Type?

When I use multiple table inheritance, Django creates two tables: one for the base class and one for the derivative, pointing to the first. Is there a way to save the record of the base table when deleting the received one and create another record for another model?

Simply put: I have models: A, B (derivatives of A), C (derived from A). I want to convert an object of type B to type C. Copying is not a good solution, because A serves as a set of elements, so points point to it using ForeignKey.

+2
source share
2 answers

. , FK , B C SQL.

RDBMS, , , B C PK, B PK.

0

, , - c b, b.items.update(itemset=c).

0

Source: https://habr.com/ru/post/1741167/


All Articles