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"