#26488: migrate raises InvalidBasesError if you rename a multitable inheritance
base model
----------------------------+------------------------------------
Reporter: chrisjrn | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Comment (by simonphilips):
I ran into the same issue. It seems that the bases of all child classes
are not updated in the state_forwards method of the RenameModel operation.
This custom operation solves it, but there may be a more elegant solution:
{{{#!python
class RenameBaseModel(migrations.RenameModel):
def state_forwards(self, app_label, state):
full_old_name = ("%s.%s" % (app_label, self.old_name)).lower()
full_new_name = ("%s.%s" % (app_label, self.new_name)).lower()
for (app, model_name), model in state.models.items():
if full_old_name in model.bases:
model.bases = tuple(full_new_name if b == full_old_name
else b
for b in model.bases)
super().state_forwards(app_label, state)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26488#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.3a42089e84536c57d1a44dd6a6870291%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.