django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. when missing env values
If DJANGO_ALLOWED_HOSTS or DJANGO_SECRET_KEY are missing, running the migrations result in a cryptic stack trace:
File "/usr/local/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 22, in MigrationRecorder
class Migration(models.Model):
File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 100, in __new__
app_config = apps.get_containing_app_config(module)
File "/usr/local/lib/python3.5/site-packages/django/apps/registry.py", line 244, in get_containing_app_config
self.check_apps_ready()
File "/usr/local/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.
we should improve this error handling to make it easier to spot the missing value.