1

I am running a new django project and when I run makemigrations I get this error :

ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'login.stylista', but app 'login' isn't installed.

The field authtoken.Token.user was declared with a lazy reference to 'login.stylista', but app 'login' isn't installed.

I haven't put login app in the INSTALLED_APPS settings and I haven't put 'login.stylista' as the AUTH_USER_MODEL. Here are my settings:

    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'rest_framework.authtoken',
    'accounts',
    'events',
    'gallery'
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'wyat.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'wyat.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]



#User Model

AUTH_USER_MODEL = 'accounts.user'



# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

STATIC_URL = '/static/'

As you can see I haven't made any references to login or login.stylista because that is a different project. I have uninstalled and reinstalled django and django rest framework but the error remains the same.

SaeX
  • 17,240
  • 16
  • 77
  • 97
zacmwa
  • 578
  • 10
  • 28
  • Are you running your app in the correct (virtual) environment? – voodoo-burger Dec 15 '16 at 09:25
  • @voodoo-burger Yes it's the same virtual environment I have been running for a long time the problem only started now. – zacmwa Dec 15 '16 at 09:39
  • if this is a fresh project you should also use a fresh virtualenv – voodoo-burger Dec 15 '16 at 10:07
  • Related: http://stackoverflow.com/questions/40222268/valueerror-in-django-when-running-the-python-manage-py-migrate-command/ – SaeX Dec 15 '16 at 14:30
  • @voodoo-burger while it's usefull to do so and certainly a good practice, it's not compulsory. – e4c5 Dec 16 '16 at 03:05
  • you have left out the most important part the model that raises the error. Anyway, it's clear from your settings.py that you don;t actually have an app called login in yur installed_apps. So this error is the most natural result. – e4c5 Dec 16 '16 at 03:07
  • I change the virtual environment and the error went away. – zacmwa Dec 16 '16 at 07:02

1 Answers1

0

try removing 'rest_framework.authtoken' and then run python manage.py makemigrations.

It should give no error.

cyberspider789
  • 379
  • 3
  • 9