[Django]-South data migration from parent class to subclass clobbers parent data

0👍

The problem is in get_or_create. It is working differently than you expect to.

There are two ways to solve this:

  • don’t use get_or_create, or
  • debug the problem

To debug the problem you should:

  • read get_or_create documentation
  • maybe read get_or_create implementation
  • look at produced SQL statements

0👍

The problem isn’t in south, it’s in your use of subclasses

When you save a subclass, it sets all the values in the database from its fields.
Your sosc object has been created with all of it’s parent derived fields at their default values.

When you save the subclass, it overwrites the parent.
Then soc.save() resets the parent again to it’s original values.

See https://code.djangoproject.com/ticket/7623

Leave a comment