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??
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
asDEGUB
instead ofDEBUG
(note the misspelling) and that caused the error.I was getting a similar error and I am a total novice programmer. One solution that worked for me was installing sqlparse. Try
For my case the LookupError was occuring because I had altered the models and added 'related_name' but had not run makemigrations and migrate.