Opened 8 years ago

Closed 8 years ago

#22743 closed Bug (duplicate)

django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<django.db.migrations.state.ModelState object at 0x2c15c10>]

Reported by: jscott1971 Owned by: nobody
Component: Migrations Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Subject : InvalidBasesError when running manage.py migrate

I created a new app, and succesfully ran makemigrations.
However, when I run migrate, I get the following error:
django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<django.db.migrations.state.ModelState object at 0x2c46b10>]

===============
python ../manage.py --version
1.8.dev20140530195842

===============

python ../manage.py migrate
Operations to perform:
....
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying continent.0001_initial...Traceback (most recent call last):
  File "../manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/django/virtualenvs/mysite/src/django/django/core/management/__init__.py", line 384, in execute_from_command_line
    utility.execute()
  File "/home/django/virtualenvs/mysite/src/django/django/core/management/__init__.py", line 376, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/django/virtualenvs/mysite/src/django/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/django/virtualenvs/mysite/src/django/django/core/management/base.py", line 337, in execute
    output = self.handle(*args, **options)
  File "/home/django/virtualenvs/mysite/src/django/django/core/management/commands/migrate.py", line 146, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/home/django/virtualenvs/mysite/src/django/django/db/migrations/executor.py", line 62, in migrate
    self.apply_migration(migration, fake=fake)
  File "/home/django/virtualenvs/mysite/src/django/django/db/migrations/executor.py", line 90, in apply_migration
    if self.detect_soft_applied(migration):
  File "/home/django/virtualenvs/mysite/src/django/django/db/migrations/executor.py", line 134, in detect_soft_applied
    apps = project_state.render()
  File "/home/django/virtualenvs/mysite/src/django/django/db/migrations/state.py", line 68, 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 0x2c46b10>]

===============
0001_initial.py

class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Continent',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('code', models.CharField(help_text='Continent code', unique=True, max_length=2, verbose_name='code')),
                ('name', models.CharField(help_text='Continent name', max_length=13, verbose_name='name')),
                ('display', models.BooleanField(default=True, help_text='Display continent', verbose_name='display')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, verbose_name='last modified')),
            ],
            options={
                'verbose_name': 'continent',
                'verbose_name_plural': 'continents',
            },
            bases=(models.Model,),
        ),
    ]

===============
models.py

from django.db import models
from django.utils.translation import ugettext_lazy as _

class Continent(models.Model):
    code = models.CharField(_('code'), max_length=2, unique=True, help_text=_("Continent code"))
    name = models.CharField(_('name'), max_length=13, help_text=_("Continent name"))

    display = models.BooleanField(_('display'), default=True, help_text=_("Display continent"))

    created = models.DateTimeField(_('created'), auto_now_add=True)
    last_modified = models.DateTimeField(_('last modified'), auto_now=True)

    class Meta:
        verbose_name = _('continent')
        verbose_name_plural = _('continents')

    def __unicode__(self):
        return "%s" % (self.name)

    def get_absolute_url(self):
        return "/continent/%s/" % (self.code)

Change History (2)

comment:1 Changed 8 years ago by jscott1971

Type: UncategorizedBug

comment:2 Changed 8 years ago by Tim Graham

Resolution: duplicate
Status: newclosed

Looks like a duplicate of #22708,

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