I have noticed, that I need a generalized model based on a specified model, following example should show what I mean:
before:
class TextResult(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
text = models.ForeignKey(Text)
wpm = models.FloatField(default=0.0)
accuracy = models.FloatField(default=1.0)
after:
class TypingResult(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
wpm = models.FloatField(default=0.0)
accuracy = models.FloatField(default=1.0)
class TextResult(TypingResult):
text = models.ForeignKey(Text)
Though there is already some data in the original model, so it is necessary to migrate the data to the new modelstructure
The following answer is based on this answer(https://stackoverflow.com/a/44148102/4129587)
In order to achieve that it is necessary to do a manual Data Migration
The following 5 basic migration steps lead to the desired result:
TypingResult
TypingResult
in the old modelTextResult
TypingResult
It might be possible to start the migration with an autogenerated migration of the new models
The following code is based on an automatically generated migration and already tested