2

I'm getting

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet

error in django==2.0.2 and celery==4.1.0. No search helped me around. I tried

import django
django.setup()

But it seems that this did not work for me. Here is the traceback:

[2018-06-05 10:41:42,529: ERROR/ForkPoolWorker-1] Task backend.ml.face_detection_request[891df311-fe6b-4456-8c30-84a0b9baf716] raised unexpected: AppRegistryNotReady("Apps aren't loaded yet.",)
Traceback (most recent call last):
  File "/home/user/lib/python3.5/site-packages/celery/app/trace.py", line 374, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/user/lib/python3.5/site-packages/celery/app/trace.py", line 629, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/user/wandresearchrepo/wandhub/wandhub/backend/ml.py", line 89, in face_detection_request
    from backend.models import Image
  File "/home/user/backend/models.py", line 6, in <module>
    class Company(models.Model):
  File "/home/user/lib/python3.5/site-packages/django/db/models/base.py", line 100, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/user/lib/python3.5/site-packages/django/apps/registry.py", line 244, in get_containing_app_config
    self.check_apps_ready()
  File "/home/user/lib/python3.5/site-packages/django/apps/registry.py", line 127, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
jhonkola
  • 3,385
  • 1
  • 17
  • 32
Prakash
  • 100
  • 10
  • i think you can't find because, other people put image in the question instead of text. – Brown Bear Jun 05 '18 at 11:26
  • @BearBrown just updated the question. – Prakash Jun 05 '18 at 11:35
  • 2
    Possible error could be due to config issue in celery. Are you missing specifying the apps list? – Vinay P Jun 05 '18 at 11:45
  • @VinayP There are two apps in my project 1. backend 2. webapi added it in the installed_apps like `backend.apps.BackendConfig`, `webapi.apps.WebapiConfig` – Prakash Jun 05 '18 at 11:59
  • 1
    take a look at this recent [question](https://stackoverflow.com/questions/50671044/apps-arent-loaded-yet-when-trying-to-import-model-in-a-celery-tasks-file) or just add your celery configuration, and the tree of your project – Lemayzeur Jun 05 '18 at 12:40
  • My Project structure would be `- proj/ - manage.py - proj/ - __init__.py - settings.py - celery.py - urls.py - backend - tasks.py - webapi` – Prakash Jun 05 '18 at 12:57

0 Answers0