Django migration fails for ForeignKey to custom user model -



Django migration fails for ForeignKey to custom user model -

when run migration new model has foreignkey custom user model, error:

valueerror: lookup failed model referenced field test.testmodel.user: account.emailuser

it's in django 1.7.

my custom user apps.models.emailuser.

here's relevant code:

# apps.test/models.py django.db import models django.conf import settings class testmodel(models.model): user = models.foreignkey(settings.auth_user_model) # settings.py auth_user_model = 'account.emailuser' installed_apps = ( ... 'apps.account', 'apps.test', )

finally, here's migration file:

# -*- coding: utf-8 -*- __future__ import unicode_literals django.db import models, migrations django.conf import settings class migration(migrations.migration): dependencies = [ migrations.swappable_dependency(settings.auth_user_model), ] operations = [ migrations.createmodel( name='testmodel', fields=[ ('id', models.autofield(verbose_name='id', serialize=false, auto_created=true, primary_key=true)), ('user', models.foreignkey(to=settings.auth_user_model)), ], options={ }, bases=(models.model,), ), ] full error traceback running migrations: applying test.0001_initial...traceback (most recent phone call last): file "./manage.py", line 4, in <module> manage_environment() file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/bobsleigh/runner/__init__.py", line 9, in manage_environment execute_from_command_line(sys.argv) file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute output = self.handle(*args, **options) file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 160, in handle executor.migrate(targets, plan, fake=options.get("fake", false)) file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 63, in migrate self.apply_migration(migration, fake=fake) file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 91, in apply_migration if self.detect_soft_applied(migration): file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 135, in detect_soft_applied apps = project_state.render() file "/home/david/.virtualenvs/lingoing/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 89, in render model=lookup_model, valueerror: lookup failed model referenced field test.testmodel.user: account.emailuser extra info

i notice there test see if it's using custom user model in django.db.migrations.state.render(), takes test if render called ignore_swappable=true, isn't in case.

any ideas anyone?

django django-1.7 django-migrations

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -