Django version 1.7b4
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Migrations for 'account':
0004_auto_20140527_1518.py:
- Create model LoginFailed
- Alter field ip on loginactivity
dmitrij$ python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: ***
Apply all migrations: account, ***
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying account.0004_auto_20140527_1518...Traceback (most recent call
last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/dmitrij/dev/django/django/core/management/__init__.py",
line 427, in execute_from_command_line
utility.execute()
File "/Users/dmitrij/dev/django/django/core/management/__init__.py",
line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/dmitrij/dev/django/django/core/management/base.py", line
288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/dmitrij/dev/django/django/core/management/base.py", line
337, in execute
output = self.handle(*args, **options)
File
"/Users/dmitrij/dev/django/django/core/management/commands/migrate.py",
line 146, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/Users/dmitrij/dev/django/django/db/migrations/executor.py", line
62, in migrate
self.apply_migration(migration, fake=fake)
File "/Users/dmitrij/dev/django/django/db/migrations/executor.py", line
90, in apply_migration
if self.detect_soft_applied(migration):
File "/Users/dmitrij/dev/django/django/db/migrations/executor.py", line
134, in detect_soft_applied
apps = project_state.render()
File "/Users/dmitrij/dev/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 0x102f19ad0>,
<django.db.migrations.state.ModelState object at 0x102f19b90>,
<django.db.migrations.state.ModelState object at 0x102f19c50>]
---0004_auto_20140527_1518.py---
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.utils.timezone
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('account', '0003_loginactivity'),
]
operations = [
migrations.CreateModel(
name='LoginFailed',
fields=[
('id', models.AutoField(verbose_name='ID',
serialize=False, auto_created=True, primary_key=True)),
('user', models.ForeignKey(to_field='id', blank=True,
to=settings.AUTH_USER_MODEL, null=True)),
('username', models.CharField(max_length=120)),
('password', models.CharField(max_length=120, null=True,
blank=True)),
('created',
models.DateField(default=django.utils.timezone.now)),
('ip', models.GenericIPAddressField(null=True,
blank=True)),
],
options={
},
bases=(models.Model,),
),
migrations.AlterField(
model_name='loginactivity',
name='ip',
field=models.GenericIPAddressField(),
),
]
--
Ticket URL: <https://code.djangoproject.com/ticket/22708>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 0
Old description:
New description:
---0004_auto_20140527_1518.py---
class Migration(migrations.Migration):
--
Comment:
Could you include the models as well? Particularly, if there are any that
do more than just inherit from `models.Model`. I suspect the problem lies
somewhere in there.
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:1>
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:2>
Comment (by strelnikovdmitrij):
hi Timo,
all my models are inherit from models.Model or AbstractBase for User
custom model
if you still want to provide them - which one do you need?
regards,
Dmitrij
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:3>
Comment (by timo):
We need a minimal set of models to reproduce the issue. #22743 seems to be
a duplicate and the models provided there may be enough.
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:4>
Comment (by timo):
I couldn't reproduce this with the models in #22743. I wonder if it might
be more than just the models themselves. For example, #22660 reports this
error when there are dependencies between migrate and unmigrated apps.
Could this be the same issue?
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:5>
* status: new => closed
* resolution: => needsinfo
Comment:
Please retest with the latest master or stable/1.7.x and reopen with
details if this is still an issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:6>
* status: closed => new
* resolution: needsinfo =>
Comment:
This seems to have regressed. I can reproduce the error with these models
on today's stable/1.7.x
{{{
#!python
from django.contrib.contenttypes.models import ContentType
from django.db import models
class PageElement(models.Model):
content_type = models.ForeignKey(ContentType)
class Link(PageElement):
href = models.CharField(max_length=255)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:7>
* severity: Normal => Release blocker
Comment:
Sorry, posted that last comment anonymously (and before finishing). I've
attached an example project to reproduce the exception. This example is
fairly basic and doesn't use swappable models. Just basic model
inheritance. The starnge thing is, if you rename "PageEleemnt" to
"BaseElement", the migration works. This leads me to believe theirs a dict
or set is being used somewhere where order is important.
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:8>
Comment (by CollinAnderson):
I can confirm that the simple `testproject` does not work either on the
latest 1.7.x or on master, and that it works fine if the model is named
`BaseElement`.
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:9>
Comment (by CollinAnderson):
I believe the issue is that the auto-generated migration creates Link
first (with base PageElement), then creates PageElement second:
{{{
operations = [
migrations.CreateModel(
name='Link',
fields=[
('href', models.CharField(max_length=255)),
],
options={
},
bases=('testapp.pageelement',),
),
migrations.CreateModel(
name='PageElement',
fields=[
('id', models.AutoField(verbose_name='ID',
serialize=False, auto_created=True, primary_key=True)),
('content_type',
models.ForeignKey(to='contenttypes.ContentType', to_field='id')),
],
options={
},
bases=(models.Model,),
),
migrations.AddField(
model_name='link',
name='pageelement_ptr',
field=models.OneToOneField(auto_created=True,
primary_key=True, to_field='id', serialize=False,
to='testapp.PageElement'),
preserve_default=True,
),
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:10>
* cc: cmawebsite@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:11>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:12>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"fe262c0b848c96ef624680d43dc78eae55157967"]:
{{{
#!CommitTicketReference repository=""
revision="fe262c0b848c96ef624680d43dc78eae55157967"
Fixed #22708: Typo in autodetector base dependency gen
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:13>
Comment (by Andrew Godwin <andrew@…>):
In [changeset:"48a2e027bf5eeca75b7694ea0b3c271dc46ae094"]:
{{{
#!CommitTicketReference repository=""
revision="48a2e027bf5eeca75b7694ea0b3c271dc46ae094"
[1.7.x] Fixed #22708: Typo in autodetector base dependency gen
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:14>
Comment (by riklaunim):
I've made a stabke.1.7.x checkout now with that commit and still
contenttypes doesn't want to migrate.
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:15>
* status: closed => new
* resolution: fixed =>
Comment:
Hi there,
Same problem here with a fresh checkout of stable/1.7.x when running my
tests (which used to works a few weeks ago):
{{{
Creating test database for alias 'default'...
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/__init__.py", line
385, in execute_from_command_line
utility.execute()
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/__init__.py", line
377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/commands/test.py",
line 50, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/base.py", line 288,
in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/commands/test.py",
line 71, in execute
super(Command, self).execute(*args, **options)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/base.py", line 337,
in execute
output = self.handle(*args, **options)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/commands/test.py",
line 88, in handle
failures = test_runner.run_tests(test_labels)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/test/runner.py", line 147, in
run_tests
old_config = self.setup_databases()
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/test/runner.py", line 109, in
setup_databases
return setup_databases(self.verbosity, self.interactive, **kwargs)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/test/runner.py", line 299, in
setup_databases
serialize=connection.settings_dict.get("TEST_SERIALIZE", True),
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/db/backends/creation.py", line 374,
in create_test_db
test_flush=True,
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/__init__.py", line
115, in call_command
return klass.execute(*args, **defaults)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/base.py", line 337,
in execute
output = self.handle(*args, **options)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/core/management/commands/migrate.py",
line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/db/migrations/executor.py", line
62, in migrate
self.apply_migration(migration, fake=fake)
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/db/migrations/executor.py", line
90, in apply_migration
if self.detect_soft_applied(migration):
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/db/migrations/executor.py", line
134, in detect_soft_applied
apps = project_state.render()
File "/Users/stan/src/venv_dj_1_7/lib/python2.7/site-
packages/Django-1.7c1-py2.7.egg/django/db/migrations/state.py", line 71,
in render
raise InvalidBasesError("Cannot resolve bases for %r" %
new_unrendered_models)
InvalidBasesError: Cannot resolve bases for [<ModelState:
'parametrage.Support'>, <ModelState: 'parametrage.Commercial'>,
<ModelState: 'parametrage.Assistant'>, <ModelState:
'parametrage.Production'>, <ModelState: 'parametrage.Traducteur'>]
make: *** [test] Error 1
}}}
I am not using migrations.
Here my models.py:
{{{
from django.contrib.sites.models import Site
from django.contrib.auth.models import User
class Support(Site):
short_name = models.CharField('nom court', max_length=10, unique=True)
logo = models.ImageField('logo', upload_to='images/supports',
blank=True)
site_ptr = models.OneToOneField(Site, primary_key=True)
objects = SupportManager()
class Employe(User):
supports = models.ManyToManyField(Support)
organisation = models.ForeignKey('Organisation', null=True,
blank=True)
filtre_organisation = models.BooleanField(default=False)
telephone = models.CharField(u'téléphone', max_length=100, blank=True)
class Meta:
abstract = True
ordering = ('last_name', 'first_name')
def __unicode__(self):
return self.get_full_name()
def supports_txt(self):
return ', '.join([str(s) for s in self.supports.all()])
supports_txt.short_description = 'supports'
class Commercial(Employe):
class Meta:
verbose_name_plural = 'commerciaux'
ordering = ('first_name', 'last_name')
class Assistant(Employe):
class Meta:
verbose_name = 'chargé de clientèle'
verbose_name_plural = 'chargés de clientièle'
class Production(Employe):
class Meta:
verbose_name = 'chargé de production'
verbose_name_plural = 'chargés de production'
class Traducteur(Employe):
pass
}}}
Cheers,
Stanislas.
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:16>
* status: new => closed
* resolution: => fixed
Comment:
It's a separate issue. #22965
--
Ticket URL: <https://code.djangoproject.com/ticket/22708#comment:17>