#26488: migration raises django.db.migrations.exceptions.InvalidBasesError if
you
rename a base model
----------------------------+--------------------
Reporter: chrisjrn | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
I needed to rename the base class that several models depend on due to a
change in naming conventions in my product. It appears as though this is
not possible.
I was able to reproduce this in Django 1.9.2 with the following simple
case:
Steps to reproduce:
Create a fresh django project, and populate models.py like so:
{{{
from django.db import models
class Base(models.Model):
foo = models.BooleanField()
class SubA(Base):
bar = models.BooleanField()
}}}
Run makemigrations to get an initial migration file.
Replace the contents of models.py with the following:
{{{
from django.db import models
class BrokenBase(models.Model):
foo = models.BooleanField()
class SubA(BrokenBase):
bar = models.BooleanField()
}}}
Run makemigrations, and accept all of the y/N questions. It correctly
detects the renames, like so:
{{{
Did you rename the oops.Base model to BrokenBase? [y/N] y
Did you rename suba.base_ptr to suba.brokenbase_ptr (a OneToOneField)?
[y/N] y
}}}
Now run migrate:
{{{
django.db.migrations.exceptions.InvalidBasesError: Cannot resolve bases
for [<ModelState: 'oops.SubA'>]
This can happen if you are inheriting models from an app with migrations
(e.g. contrib.auth)
in an app with no migrations; see
https://docs.djangoproject.com/en/1.9/topics/migrations/#dependencies for
more
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26488>
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/051.414d04b4d1b8f2715f94fcfe349ad9cb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.