Skip to content

Instantly share code, notes, and snippets.

@neerajgupta2407
Last active December 29, 2020 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neerajgupta2407/762c93ff3aac588ff53f62baa67801cc to your computer and use it in GitHub Desktop.
Save neerajgupta2407/762c93ff3aac588ff53f62baa67801cc to your computer and use it in GitHub Desktop.
ALLOWED_HOSTS=x.x.x.x
ALLOWED_CLIENT_HOSTS=x.x.x.x
DEBUG=True
SECRET_KEY=12345678
INTERNAL_IPS=127.0.0.1,x.x.x.x,
DEFAULT_COUNTRY=IN
DEFAULT_CURRENCY=INR
APP_MOUNT_URI=/dashboard/
API_URI=http://x.x.x.x:8000/graphql/
#!/usr/bin/env python3
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "saleor.settings")
try:
from decouple import RepositoryEnv
file_path = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
#print("{}/.env".format(file_path))
for k,v in RepositoryEnv("{}/.env".format(file_path)).data.items():
print(k, v)
os.environ[k] = v
except Exception as e:
#print(e)
pass
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
1) Install python decpuple: pip install python-decouple
2. create .env file at root path. (in folder where manage.py exists) and update the below values.
3.) Append below code in setting.py just above 'get_list' function.
try:
from decouple import RepositoryEnv
file_path = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
#print("{}/.env".format(file_path))
for k,v in RepositoryEnv("{}/.env".format(file_path)).data.items():
print(k, v)
os.environ[k] = v
except Exception as e:
#print(e)
pass
### Alternativly, since there is not going to be any change manage.py file, so you can also edit it . Find the attached file.
Sample code:
try:
from decouple import RepositoryEnv
file_path = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
#print("{}/.env".format(file_path))
for k,v in RepositoryEnv("{}/.env".format(file_path)).data.items():
print(k, v)
os.environ[k] = v
except Exception as e:
#print(e)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment