“No installed app with label 'admin'” runn

2020-02-26 03:12发布

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??

9条回答
家丑人穷心不美
2楼-- · 2020-02-26 04:03

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.

查看更多
叼着烟拽天下
3楼-- · 2020-02-26 04:04

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

查看更多
我想做一个坏孩纸
4楼-- · 2020-02-26 04:04

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

查看更多
登录 后发表回答