django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet. (django 2.0.1)(Python 3.6)

Overcame similar situation just now.

All you really need is this:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_project.settings")

And then these lines:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

After that you can easily import models without AppRegistryNotReady: Apps aren't loaded yet.

UPDATE: This is really exactly the 4 code lines from wsgi.py file in your project’s folder.

FOR DJANGO 3.0
In Django 3+ an extra variable is needed to resolve sync/async confusing:

os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)