-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·30 lines (26 loc) · 1.24 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
import os
import sys
import dotenv
if __name__ == "__main__":
if 'test' in sys.argv:
os.environ.setdefault('TESTING', 'True')
dotenv.read_dotenv()
SETTINGS_FILE = os.environ.get('DJANGO_SETTINGS_MODULE', 'backoffice.settings.local')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", SETTINGS_FILE)
from django.core.management import execute_from_command_line
try:
execute_from_command_line(sys.argv)
except KeyError as ke:
print("Error loading application.")
print("The following environment var is not defined : {}".format(str(ke)))
print("Check the following possible causes :")
print(" - You don't have a .env file. You can copy .env.example to .env to use default")
print(" - Mandatory variables are not defined in your .env file.")
sys.exit("SettingsKeyError")
except ImportError as ie:
print("Error loading application : {}".format(str(ie)))
print("Check the following possible causes :")
print(" - The DJANGO_SETTINGS_MODULE defined in your .env doesn't exist")
print(" - No DJANGO_SETTINGS_MODULE is defined and the default 'backoffice.settings.local' doesn't exist ")
sys.exit("DjangoSettingsError")