﻿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
22563	Migration of admin.LogEntry.user fails.	efrinut@…	Andrew Godwin	"I am not 100% sure if this will help with reproducing the issue.

I've set up a postgresql databasae with app and model config which is below.

When I try to migrate I get an error:

{{{
ValueError: Lookup failed for model referenced by field admin.LogEntry.user: accounts.User
}}}

To fix this error error I did these steps:
1. Commented out django.contrib.admin and admin in urls.py
2. Applied migrations
3. Uncommented django.contrib.admin and urls.py


{{{
DJANGO_APPS = (
    'django.contrib.contenttypes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admindocs',
    'django.contrib.humanize',
    'django.contrib.sitemaps',
    'django.contrib.flatpages',
)

EXTERNAL_APPS = (
    'haystack',
    'storages',
    'pipeline',
    'endless_pagination',
    'easy_thumbnails',
    'mptt',
    'rest_framework',
    'crispy_forms',
    'crispy_forms_foundation',
    'taggit',
)


SITE_APPS = (
    'accounts',
    'core',
    'images',
    'streams',
    'links',
    'entries',
)
AUTH_USER_MODEL = 'accounts.User'

INSTALLED_APPS = DJANGO_APPS + EXTERNAL_APPS + SITE_APPS
}}}


{{{
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.core.urlresolvers import reverse


class User(AbstractUser):
    description = models.TextField(null=True, blank=True, verbose_name=u""Write something about yourself"")
    link_blank = models.BooleanField(default=False, verbose_name=u""Open links in new window"")
    link_direct = models.BooleanField(default=False, verbose_name=u""Skip directly to the link"")

    def get_absolute_url(self):
        return reverse(""user:detail"", kwargs={'pk': self.pk})

    def get_edit_url(self):
        return reverse(""user:edit"", kwargs={'pk': self.pk})

}}}


{{{

WARNINGS:
?: (1_6.W001) Some project unittests may not execute as expected.
        HINT: Django 1.6 introduced a new default test runner. It looks like thi
s project was generated using Django 1.5 or earlier. You should ensure your test
s are all running & behaving as expected. See https://docs.djangoproject.com/en/
dev/releases/1.6/#new-test-runner for more information.
Operations to perform:
  Synchronize unmigrated apps: pipeline, mptt, sessions, admin, debug_toolbar, s
ites, auth, easy_thumbnails, sitemaps, endless_pagination, contenttypes, flatpag
es, images, rest_framework, haystack, storages, crispy_forms, crispy_forms_found
ation
  Apply all migrations: streams, accounts, taggit
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying taggit.0001_initial...Traceback (most recent call last):
  File ""local_manage.py"", line 22, in <module>
    execute_from_command_line(sys.argv)
  File ""D:\projekty\myinit\env\lib\site-packages\django\core\management\__init__
.py"", line 427, in execute_from_command_line
    utility.execute()
  File ""D:\projekty\myinit\env\lib\site-packages\django\core\management\__init__
.py"", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""D:\projekty\myinit\env\lib\site-packages\django\core\management\base.py""
, line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""D:\projekty\myinit\env\lib\site-packages\django\core\management\base.py""
, line 337, in execute
    output = self.handle(*args, **options)
  File ""D:\projekty\myinit\env\lib\site-packages\django\core\management\commands
\migrate.py"", line 146, in handle
    executor.migrate(targets, plan, fake=options.get(""fake"", False))
  File ""D:\projekty\myinit\env\lib\site-packages\django\db\migrations\executor.p
y"", line 60, in migrate
    self.apply_migration(migration, fake=fake)
  File ""D:\projekty\myinit\env\lib\site-packages\django\db\migrations\executor.p
y"", line 88, in apply_migration
    if self.detect_soft_applied(migration):
  File ""D:\projekty\myinit\env\lib\site-packages\django\db\migrations\executor.p
y"", line 132, in detect_soft_applied
    apps = project_state.render()
  File ""D:\projekty\myinit\env\lib\site-packages\django\db\migrations\state.py"",
 line 80, in render
    model=lookup_model
ValueError: Lookup failed for model referenced by field admin.LogEntry.user: accounts.User
}}}
"	Bug	closed	Migrations	1.7-beta-2	Release blocker	fixed		stephen.r.burrows@… k@… loic84 Nick Polet chtimbo@… murfi jeroen@… berto beathan no jezevec Selwin Ong Ben Davis lemuelf@… ludovic.legendart@… joar-5m dbinetti@… Giacomo Graziosi	Accepted	0	0	0	0	0	0
