Opened 10 years ago

Last modified 6 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: dev
Severity: Normal Keywords:
Cc: info+coding@…, bugs@…, ericmills2@…, Charlie Denton, Ian Foote, Daniel Rios, Sardorbek Imomaliev 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 by Sergey Fedoseev, 10 years ago

Component: UncategorizedMigrations
Type: UncategorizedBug

comment:2 by Baptiste Mispelon, 10 years ago

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.

in reply to:  2 comment:3 by Sergey Fedoseev, 10 years ago

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 by Baptiste Mispelon, 10 years ago

Triage Stage: UnreviewedAccepted

Thanks, that's the bit I was missing.

comment:5 by Markus Holtermann, 10 years ago

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