22👍
This could well be an issue with your Django settings. For example, I just had specified in LOGGING
a filename in a non-existent directory. As soon as I changed it to an existing directory, the issue was resolved.
14👍
I ran into this issue today. There was an app in INSTALLED_APPS that didn’t exist. Once it was removed, it resolved the exception. Apps that can’t be imported for any reason will also raise an AppRegistryNotReady exception.
Here’s the bug history for this issue.
Additionally, trying to import something from the app level into the project level can cause this issue, too. For example, I’m currently working on project using Celery Beat. I tried defining task schedules at the app level as dictionaries which were then imported to the celery.py file of the project. Importing the dictionary from the app into the project caused Django to throw an AppRegistryNotReady exception. Likewise, importing items between apps can cause the exception.
- [Django]-"<Message: title>" needs to have a value for field "id" before this many-to-many relationship can be used.
- [Django]-Django dynamically filtering with q objects
- [Django]-How do I do a not equal in Django queryset filtering?
9👍
I got this error when I tried loading a Django ORM model from inside of my Celery tasks file (which is not loaded by WSGI). To fix it, I put the following initialization code at the top above the import for the model class.
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproj.settings")
django.setup()
# Django dependencies below this line
from myapp.models import MyModel
Django docs recommend this unusual approach here: https://docs.djangoproject.com/en/4.1/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage
- [Django]-Passing **kwargs to Django Form
- [Django]-Django ModelForm: What is save(commit=False) used for?
- [Django]-Django excel xlwt
5👍
./manage.py runserver
will use your wsgi.py
however it looks like the stack trace you’ve shown at the top does not include the wsgi file. Therefore the error is occurring before the wsgi file is loaded.
I’m not able to recreate your error, but since you seem to be using the new style wsgi and as you mention “the django version on the server is 1.8.5, and the local is 1.8.1”, I’m wondering if there might be something wrong in your environment.
My suggested steps are:
- Rebuild your virtualenv. Delete the env folder and install again with
pip install -r requirements.txt
or similar. - Check out other questions on StackOverflow – this seems to be a common issue. E.g as above: Django 1.7 throws django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
Hopefully someone with more experience will be able to add suggestions. Sorry I don’t have the definitive answer for you.
- [Django]-TypeError: login() takes 1 positional argument but 2 were given
- [Django]-Virtualenv and source version control
- [Django]-Troubleshooting Site Slowness on a Nginx + Gunicorn + Django Stack
0👍
There can be issue in your settings.py file . Specifically INSTALLED_APPS verify if you correctly included apps and separated with “,” .
- [Django]-Can I have a Django model that has a foreign key reference to itself?
- [Django]-Default image for ImageField in Django's ORM
- [Django]-Django-object-permissions Vs django-guardian Vs django-authority
0👍
I got this error too regardless of the existing answers. I solve by do locally import in the celery function.
- [Django]-Django : Table doesn't exist
- [Django]-What are the differences between setUpClass, setUpTestData and setUp in TestCase class?
- [Django]-Why does django's prefetch_related() only work with all() and not filter()?
0👍
I fixed it by setting the owner of the wsgi entry point that the apache calls to root:root
- [Django]-Page not found 404 Django media files
- [Django]-Has Django served an excess of 100k daily visits?
- [Django]-Aggregating save()s in Django?
0👍
i also got the same issue when i was adding an authentication backend to my settings.py PyCharm automatically imports all requirements which are used in a file so
PyCharm imported the model and this causes an app not ready error in the registry.py check_apps_ready method
so the solution that works for me is basically check imported modules and remove unnecessary module imports the import to be removed to resolve that error
- [Django]-Django: When to use QuerySet none()
- [Django]-Running "unique" tasks with celery
- [Django]-Django ModelForm to have a hidden input
0👍
I had this error when importing a Model into apps.py
I needed this Model to use it as an argument when connecting a Signal in the ready
method.
I solved it by importing the Model inside the ready
method (in the Django docs they also do imports inside the ready method)
I leave a snippet below that shows what I did
# apps.py
from django.apps import AppConfig
from django.db.models.signals import post_save
from myproject.apps.core.utils import my_receiver
class CoreConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "tracker.apps.core"
def ready(self):
from .models import MyModel # HERE IT IS! MOVING THE IMPORT HERE SOLVED IT
post_save.connect(my_receiver, sender=MyModel)
- [Django]-Django: Difference between using server through manage.py and other servers like gunicorn etc. Which is better?
- [Django]-What is the SQL ''LIKE" equivalent on Django ORM queries?
- [Django]-Django Forms and Bootstrap – CSS classes and <divs>
0👍
In my case, python 3.8
and MacOS Ventura 13.4
this issue stemmed from context
in used. In the beginning I used spawn
and it gave the me the error. I changed it to fork
and it worked.
Roughly, spawn
creates a fresh child process that inherits the absolutely necessary resources and Django
models is not one of those. fork
though is identical to the parent and everything is loaded. However, fork may be unsafe e.g. it does not copy the parent process’s threads and thus deadlock may appear.
- [Django]-How do I use prepared statements for inserting MULTIPLE records in SQlite using Python / Django?
- [Django]-'dict' object has no attribute 'id'
- [Django]-Python MySQLDB: Get the result of fetchall in a list