Django scripting: “AppRegistryNotReady: Apps aren’t loaded yet” solution!
If you want to make a simple script that wants to import your application built on top of the Django framework, you would probably do this code:
import django from app.models import MyModel
You will probably get this error:
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet
The solution is to run your application’s
setup() before imports, as follows:
import django if __name__ == '__main__': django.setup() # import AFTER setup from app.models import MyModel # from now I can access MyModel!!