Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22922 closed Cleanup/optimization (fixed)

Add a better error messsage or an FAQ entry for InvalidBasesError

Reported by: David Burke Owned by: Andrew Godwin
Component: Migrations Version: 1.7-rc-1
Severity: Release blocker Keywords:
Cc: cmawebsite@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Extend the User model using this method

from django.contrib.auth.models import User

class Faculty(User):
    foo = models.CharField(max_length=10)

In 1.7 beta 4 this works. With 1.7RC1 I get:

Running migrations:
  Applying contenttypes.0001_initial...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 337, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 160, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 62, in migrate
    self.apply_migration(migration, fake=fake)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 90, in apply_migration
    if self.detect_soft_applied(migration):
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 134, in detect_soft_applied
    apps = project_state.render()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 71, in render
    raise InvalidBasesError("Cannot resolve bases for %r" % new_unrendered_models)
django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<django.db.migrations.state.ModelState object at 0x7f5d6af3ad50>]

Change History (10)

comment:1 by David Burke, 10 years ago

To reproduce you must not have 1.7 migrations for the app. On a app created with 1.7 you can just remove the migrations folder. I noticed the problem when trying 1.7 on an existing <1.7 django app and creating a fresh database with migrate.

comment:2 by Tim Graham, 10 years ago

You cannot have apps without migrations depend on apps with migrations which I think is the issue here. See https://docs.djangoproject.com/en/dev/topics/migrations/#dependencies

It may be worth trying to raise a more useful error message, however.

comment:3 by Tim Graham, 10 years ago

Summary: 1.7RC1 introduces InvalidBasesError when migrating with a Model that extends UserAdd a better error messsage or an FAQ entry for InvalidBasesError
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:4 by Collin Anderson, 10 years ago

Cc: cmawebsite@… added

comment:5 by Andrew Godwin, 10 years ago

Owner: changed from nobody to Andrew Godwin
Severity: NormalRelease blocker
Status: newassigned

Promoting to release blocker so we don't get more tickets like #22965.

comment:6 by Andrew Godwin <andrew@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In b02abd688a60e2dedf607e34d2cc97aca8d1c2b5:

Fixed #22922: Better error message for InvalidBasesError.

comment:7 by Andrew Godwin <andrew@…>, 10 years ago

In 23ff98888e5c183b299f29ea651c9b545ef02807:

[1.7.x] Fixed #22922: Better error message for InvalidBasesError.

comment:8 by Mathieu Agopian, 10 years ago

Scratch that, sorry for the noise, I wasn't on trunk (but on 17c1), and didn't see that this was already fixed, my bad.

I can confirm the error message is now very clear.

Last edited 10 years ago by Mathieu Agopian (previous) (diff)

comment:9 by spam@…, 10 years ago

Resolution: fixedneedsinfo

I have analog example.Solved with remove from class Meta attribute 'abstract=True' in one is many classes (Sorry for my English,this is not my native language =) )

comment:10 by Simon Charette, 10 years ago

Resolution: needsinfofixed

From what I understand you might be hitting a completely different issue.

Please don't re-open fixed tickets but open a new one with a detailed report.

Note: See TracTickets for help on using tickets.
Back to Top