62👍
The Django doc makes it clear:
When writing a RunPython function that uses models from apps other than the one in which the migration is located, the migration’s dependencies attribute should include the latest migration of each app that is involved, otherwise you may get an error similar to: LookupError: No installed app with label ‘myappname’ when you try to retrieve the model in the RunPython function using apps.get_model().
Code example:
# Imports are omitted for the sake of brevity
def move_m1(apps, schema_editor):
LogEntry = apps.get('admin.logentry')
# Other business logic here ...
class Migration(migrations.Migration):
dependencies = [
('app1', '0001_initial'),
# Below is the manually added dependency, so as to retrieve models
# of 'django.contrib.admin' app with apps.get_model() in move_m1().
#
# Currently this is for Django 1.11. You need to look into
# 'django/contrib/admin/migrations' directory to find out which is
# the latest migration for other version of Django.
('admin', '0002_logentry_remove_auto_add'),
]
operations = [
migrations.RunPython(move_m1),
]
41👍
Just check your settings.py
in the project directory and make sure that you have added your app there :
# Application definition
INSTALLED_APPS = [
# My Apps
'......'
# Default Apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
- [Django]-ImportError: No module named 'django.core.urlresolvers'
- [Django]-Django 2.0 path error ?: (2_0.W001) has a route that contains '(?P<', begins with a '^', or ends with a '$'
- [Django]-Problems extend change_form.html in django admin
9👍
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.
- [Django]-How to convert JSON data into a Python object?
- [Django]-How to customize activate_url on django-allauth?
- [Django]-How do I integrate Ajax with Django applications?
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
- [Django]-"CSRF token missing or incorrect" while post parameter via AJAX in Django
- [Django]-Django ModelForm to have a hidden input
- [Django]-Warning: Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'
2👍
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
- [Django]-How can I apply a filter to a nested resource in Django REST framework?
- [Django]-How to lookup django session for a particular user?
- [Django]-Django form – set label
2👍
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
- [Django]-Strange PostgreSQL "value too long for type character varying(500)"
- [Django]-Django Rest Framework with ChoiceField
- [Django]-Celery : Execute task after a specific time gap
2👍
In my case, app name wasn’t added to the settings.py file under "INSTALLED APPS" dictionary
- [Django]-Create empty queryset by default in django form fields
- [Django]-Is there a function for generating settings.SECRET_KEY in django?
- [Django]-How do I go straight to template, in Django's urls.py?
1👍
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.
- [Django]-Django URLs TypeError: view must be a callable or a list/tuple in the case of include()
- [Django]-How to query abstract-class-based objects in Django?
- [Django]-Laravel's dd() equivalent in django
1👍
On the Installed Applications, make sure you have the app. For instance, I have Polls under the settings.py file.
Application definition
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
- [Django]-Django REST Framework upload image: "The submitted data was not a file"
- [Django]-Render HTML to PDF in Django site
- [Django]-Remove Labels in a Django Crispy Forms
0👍
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
- [Django]-Convert an IP string to a number and vice versa
- [Django]-How to call function that takes an argument in a Django template?
- [Django]-Django edit user profile
0👍
For my case the LookupError was occuring because I had altered the models and added ‘related_name’ but had not run makemigrations and migrate.
- [Django]-Django URL Redirect
- [Django]-One-to-many inline select with django admin
- [Django]-Scoped_session(sessionmaker()) or plain sessionmaker() in sqlalchemy?
0👍
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
- [Django]-WARNING: Running pip as the 'root' user
- [Django]-Alternate Row Coloring in Django Template with More Than One Set of Rows
- [Django]-Difference between different ways to create celery task
0👍
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
- [Django]-How can I use redis with Django?
- [Django]-Is it better to use path() or url() in urls.py for django 2.0?
- [Django]-Can you perform multi-threaded tasks within Django?
0👍
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!
- [Django]-In Django, how do I check if a user is in a certain group?
- [Django]-DRF: custom ordering on related serializers
- [Django]-How can I get the file name from request.FILES?
0👍
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.
- [Django]-Http POST drops port in URL
- [Django]-Where's my JSON data in my incoming Django request?
- [Django]-Multiple ModelAdmins/views for same model in Django admin
0👍
create a virtual environment and install all the required dependency
or packages in virtual environment
- [Django]-@csrf_exempt does not work on generic view based class
- [Django]-Unable to perform collectstatic
- [Django]-Where are the Assertion Methods list from Django TestCase?
0👍
I had faced the same problem. But after some analysis, I found that I didn’t put the newly created app name into my setting.py.when I placed it then it worked.
Your setting.py will look like this one :
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
- [Django]-How can I apply a filter to a nested resource in Django REST framework?
- [Django]-Requirements.txt greater than equal to and then less than?
- [Django]-How to use subquery in django?
-2👍
You need to do makemigrations n migrate after you will not find this type of error
- [Django]-Setting the selected value on a Django forms.ChoiceField
- [Django]-Django – how to detect test environment (check / determine if tests are being run)
- [Django]-Django ImportError: cannot import name 'render_to_response' from 'django.shortcuts'