Opened 5 years ago

Last modified 7 weeks ago

#23521 assigned Bug

removal of concrete Model from bases doesn't remove it from ModelState bases — at Version 5

Reported by: Sergey Fedoseev Owned by:
Component: Migrations Version: master
Severity: Normal Keywords:
Cc: info+coding@…, bugs@…, ericmills2@…, Charlie Denton, Ian Foote, Daniel Rios Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Markus Holtermann)

Steps to reproduce:

  • add test app with models.py:
    class Thing(models.Model):
        pass
    
    
    class SuperThing(Thing):
        pass
    
  • do
manage.py makemigrations test
  • change models.py (remove Thing):
    class SuperThing(models.Model):
        thing_ptr = models.AutoField(primary_key=True)
    
  • do
manage.py makemigrations test
  • do it one more time
manage.py makemigrations test

last command results in

django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<ModelState: 'test.SuperThing'>]
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.7/topics/migrations/#dependencies for more

Change History (5)

comment:1 Changed 5 years ago by Sergey Fedoseev

Component: UncategorizedMigrations
Type: UncategorizedBug

comment:2 Changed 5 years ago by Baptiste Mispelon

Hi,

I can't reproduce the issue you're describing.

On master, the second makemigrations doesn't detect any changes.
On stable/1.7.x, it does create a migration but running it a third time works (and detects no change as expected).

As a side note, it's not possible to create an app called test because you get this error when doing manage.py startapp test:

CommandError: 'test' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.

Can you provide us with some details on how you're trigerring the issue?

Thanks.

comment:3 in reply to:  2 Changed 5 years ago by Sergey Fedoseev

Replying to bmispelon:

Hi,

Probably this is not obvious, but removal of Thing model from models.py, not only from SuperThing bases was implied.


As a side note, it's not possible to create an app called test because you get this error when doing manage.py startapp test

I have never used this for creating apps =)

comment:4 Changed 5 years ago by Baptiste Mispelon

Triage Stage: UnreviewedAccepted

Thanks, that's the bit I was missing.

comment:5 Changed 5 years ago by Markus Holtermann

Cc: info+coding@… added
Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top