'"No installed app with label 'admin'" running Django migration. The app is installed correctly

I am trying to use admin.LogEntry objects during a datamigration on Django 1.7

The 'django.contrib.admin' app is listed on INSTALLED_APPS.

On the shell, it works:

>>> from django.apps import apps
>>> apps.get_model('admin', 'LogEntry')
django.contrib.admin.models.LogEntry

But during the migration, it fails:

def do_it(apps, schema_editor):
    LogEntry = apps.get_model('admin', 'LogEntry')

Fails like this:

django-admin migrate
(...)
LookupError: No installed app with label 'admin'.

Using a debugger, I got that the 'admin' is not installed:

ipdb> apps.get_apps()
[]
ipdb> apps.all_models.keys()
['website', 'google', 'allauth', 'twitter', 'busca', 'conteudo', 'django_mobile', 'django_filters', 'videocenter', 'tinymce', 'oferta', 'programacaotv', 'contenttypes', 'suit', 'haystack', 'destaque', 'filer', 'galeria', 'auth', 'facebook', 'paintstore', 'critica', 'disqus', 'fichas', 'omeletop', 'autocomplete_light', 'modelsv1', 'temas', 'django_extensions', 'adv_cache_tag', 'taggit', 'social', 'personalidade']

WHY??



Solution 1:[1]

Just check your setting.py in the installed apps section and make sure that you have added your app there :

# Application definition

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',


        '--- you need to add your app here ---',
    ]

Solution 2:[2]

I don't know the exact cause for this. Will have to dig into the source code. but for now a workaround is add ('admin', 'name_of_last_migration_in_admin_app') to the dependencies and the migrations shall go alright.

Solution 3:[3]

I got the same error (but unrelated to the issue mentioned in question). I was using mysql db but there were no mysql client.

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        # other details like name, user, host
    }
}

I installed mysqlclient (In ubuntu & Python3):

sudo apt-get install libmysqlclient-dev
sudo apt-get install python3-dev
pip install mysqlclient

Solution 4:[4]

I was getting a similar error and I am a total novice programmer. One solution that worked for me was installing sqlparse. Try

pip install sqlparse

Solution 5:[5]

Try looking further up your stack trace too. I got this error due to a misconfigured logger but I had to look further up the trace to find this issue!

In my case I had misnamed my environment variable DJANGO_LOG_LEVL as DEGUB instead of DEBUG (note the misspelling) and that caused the error.

Solution 6:[6]

I also had this same error of "no installed app label 'admin' ". I was able to solve it by running the pip install sqlparse command

Solution 7:[7]

In my case, app name wasn't added to the settings.py file under "INSTALLED APPS" dictionary

Solution 8:[8]

For me it shows

raise LookupError(message)

LookupError: No installed app with label 'admin'.

and I solve it by pip installing every requirements manually I m using ubuntu 16.04

Solution 9:[9]

For my case the LookupError was occuring because I had altered the models and added 'related_name' but had not run makemigrations and migrate.

Solution 10:[10]

I got the error when I used 'required=False' in my model like this: slug = models.SlugField(required=False)

I changed it to: slug = models.SlugField(blank=True,null=True) and the error disappeared

Solution 11:[11]

I also got this error after changing database from sqlite to postgresql and by installing psycog2 (which is used to connect django to postgre database) my error has gone.

pip install psycog2

Solution 12:[12]

Had troubles with this too, all I did was upgrade pip and it seemed to fix itself tried installing other dependencies but turned out I already had them all so if you are in the same position try upgrading your pip!

Solution 13:[13]

The same thing also happened to me, but in my case the INSTALLED_APPS variable had been overwritten a few lines below in this file in the settings.py file.

Solution 14:[14]

create a virtual environment and install all the required dependency or packages in virtual environment

That solved my issue

Solution 15:[15]

You need to do makemigrations n migrate after you will not find this type of error