﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21786	migrate fails with certain mixin/model combinations	Gabe Jackson	Andrew Godwin	"manage migrate fails with:
{{{
Operations to perform:
  Synchronize unmigrated apps: admin, contenttypes, langapp, auth, sessions
  Apply all migrations: (none)
Synchronizing apps without migrations:
  Creating tables...
    Creating table django_admin_log
    Creating table auth_permission
    Creating table auth_group_permissions
    Creating table auth_group
    Creating table auth_user_groups
    Creating table auth_user_user_permissions
    Creating table auth_user
    Creating table django_content_type
    Creating table django_session
    Creating table langapp_mymodela_translation
    Creating table langapp_mymodela
    Creating table langapp_mymodelb_translation
    Creating table langapp_mymodelb
    Creating table langapp_mymodelc
    Creating table langapp_mymodeld
  Installing custom SQL...
  Installing indexes...
Installed 0 object(s) from 0 fixture(s)
Running migrations:
  No migrations needed.
Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/core/management/__init__.py"", line 427, in execute_from_command_line
    utility.execute()
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/core/management/__init__.py"", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/core/management/base.py"", line 244, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/core/management/base.py"", line 291, in execute
    output = self.handle(*args, **options)
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/core/management/commands/migrate.py"", line 140, in handle
    changes = autodetector.changes(graph=executor.loader.graph)
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/db/migrations/autodetector.py"", line 33, in changes
    changes = self._detect_changes()
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/db/migrations/autodetector.py"", line 62, in _detect_changes
    if not new_apps.get_model(al, mn)._meta.proxy
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/apps/registry.py"", line 183, in get_model
    return self.get_app_config(app_label).get_model(model_name.lower())
  File ""/Users/gabejackson/venv/hvad-test/lib/python2.7/site-packages/django/apps/base.py"", line 125, in get_model
    ""App '%s' doesn't have a '%s' model."" % (self.label, model_name))
LookupError: App 'langapp' doesn't have a 'mymodela' model.
}}}

given the following models.py:

{{{
from django.db import models
from hvad.models import TranslatableModel, TranslatedFields

class MyMixin(object):
    pass

# Fails
class MyModelA(TranslatableModel, MyMixin):
    translations = TranslatedFields(
        name=models.CharField(max_length=60),
    )

# Works
class MyModelB(TranslatableModel):
    translations = TranslatedFields(
        name=models.CharField(max_length=60),
    )

# Works
class MyModelC(models.Model, MyMixin):
    name=models.CharField(max_length=60),

# Works obviously
class MyModelD(models.Model):
    name=models.CharField(max_length=60),
}}}

Removing MyMixin from MyModelA and re-running migrate works (deleted the sqlite db first):

{{{
Operations to perform:
  Synchronize unmigrated apps: admin, contenttypes, langapp, auth, sessions
  Apply all migrations: (none)
Synchronizing apps without migrations:
  Creating tables...
    Creating table django_admin_log
    Creating table auth_permission
    Creating table auth_group_permissions
    Creating table auth_group
    Creating table auth_user_groups
    Creating table auth_user_user_permissions
    Creating table auth_user
    Creating table django_content_type
    Creating table django_session
    Creating table langapp_mymodela_translation
    Creating table langapp_mymodela
    Creating table langapp_mymodelb_translation
    Creating table langapp_mymodelb
    Creating table langapp_mymodelc
    Creating table langapp_mymodeld
  Installing custom SQL...
  Installing indexes...
Installed 0 object(s) from 0 fixture(s)
Running migrations:
  No migrations needed.

You have installed Django's auth system, and don't have any superusers defined.
Would you like to create one now? (yes/no): no
}}}

These tests have been conducted with hvad master (github) and django master (github)"	Bug	closed	Migrations	dev	Normal	fixed	migrations	Tim Graham	Accepted	0	0	0	0	0	0
