Advertisement
juanmd

manage.py Proyecto 2 UCN

May 12th, 2022
620
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import sys
  3. import json
  4. from django.core.exceptions import ImproperlyConfigured
  5.  
  6.  
  7. with open("global_data.json") as f:
  8.     value = json.loads(f.read())
  9.    
  10.  
  11. def get_value(value_title, values=value):
  12.     try:
  13.         return values[value_title]
  14.     except:
  15.         msg = f"The name of {value_title} doesn't exists"
  16.         raise ImproperlyConfigured(msg)
  17.    
  18.  
  19. def main():
  20.     """Run administrative tasks."""
  21.     if get_value("ENVIRONMENT") == "local":
  22.         os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"{get_value('CORE_APP')}.settings.local")
  23.     else:
  24.         os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"{get_value('CORE_APP')}.settings.prod")
  25.    
  26.    
  27.     try:
  28.         from django.core.management import execute_from_command_line
  29.     except ImportError as exc:
  30.         raise ImportError(
  31.             "Couldn't import Django. Are you sure it's installed and "
  32.             "available on your PYTHONPATH environment variable? Did you "
  33.             "forget to activate a virtual environment?"
  34.         ) from exc
  35.     execute_from_command_line(sys.argv)
  36.    
  37. if __name__ == '__main__':
  38.     main()
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement