-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
From models.py:
from django.db import models
from modelmixins import ModelMixin
class AMixin(ModelMixin):
field_from_a = models.CharField(max_length=32)
class BMixin(ModelMixin):
field_from_b = models.CharField(max_length=32)
class MyModel(AMixin, BMixin, models.Model):
my_model_field = models.IntegerField(default=42)Created initial migration using python manage.py makemigrations foo,
then 0001_initial.py shows:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import foo.models
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='MyModel',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('field_from_a', models.CharField(max_length=32)),
('field_from_b', models.CharField(max_length=32)),
('my_model_field', models.IntegerField(default=42)),
],
options={
},
bases=(foo.models.AMixin, foo.models.BMixin, models.Model),
),
]So far, so good.
Next, python manage.py migrate,
Result:
Running migrations:
Applying foo.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "***/.python-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "***/.python-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "***/.python-env/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "***/.python-env/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "***/.python-env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "***/.python-env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate
self.apply_migration(migration, fake=fake)
File "***/.python-env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 102, in apply_migration
migration.apply(project_state, schema_editor)
File "***/.python-env/lib/python2.7/site-packages/django/db/migrations/migration.py", line 108, in apply
operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
File "***/.python-env/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 36, in database_forwards
schema_editor.create_model(model)
File "***/.python-env/lib/python2.7/site-packages/django/db/backends/schema.py", line 262, in create_model
self.execute(sql, params)
File "***/.python-env/lib/python2.7/site-packages/django/db/backends/schema.py", line 103, in execute
cursor.execute(sql, params)
File "***/.python-env/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "***/.python-env/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "***/.python-env/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "***/ctsweb/.python-env/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "field_from_a" specified more than oncewhere *** is the project path.
Any ideas what is going on? If I comment out the fields contributed from AMixin and BMixin in 0001_initial.py, then the migration runs without error and the db tables are correct.
Metadata
Metadata
Assignees
Labels
No labels