diff --git a/api/manage.py b/api/manage.py index d99574ebe2ac8b7f8381d768b4651cb002561e1f..c8db95ede2a7c2a36c4f2368ab77d1d600be3972 100755 --- a/api/manage.py +++ b/api/manage.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +import django import os import sys @@ -7,6 +8,12 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__))) if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") + # we're doing this here since otherwise, missing environment + # files in settings result in AttributeError being raised, generating + # a cryptic django.core.exceptions.AppRegistryNotReady error. + # To prevent that, we explicitely load settings here before anything + # else, so we fail fast with a relevant error. See #140 for more details. + django.setup() from django.core.management import execute_from_command_line diff --git a/changes/changelog.d/140.enhancement b/changes/changelog.d/140.enhancement new file mode 100644 index 0000000000000000000000000000000000000000..9bc3aab950fd018dbb5a87fe3442e678ff01bce6 --- /dev/null +++ b/changes/changelog.d/140.enhancement @@ -0,0 +1 @@ +Better error messages in case of missing environment variables (#140)