import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "OIPA.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

import os
import sys

from dotenv import find_dotenv, load_dotenv

load_dotenv(find_dotenv())

if __name__ == "__main__":
    current_settings = os.getenv("DJANGO_SETTINGS_MODULE", None)

    if not current_settings:
        raise Exception(
            "Please configure your .env file along-side manage.py file and "
            "set 'DJANGO_SETTINGS_MODULE=OIPA.settings_file' variable there!"
        )

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", current_settings)

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

Load current settings from .env file
Load current settings from .env file

OIPA-645

  import os
  import sys
  
+ from dotenv import find_dotenv, load_dotenv
+ 
+ load_dotenv(find_dotenv())
+ 
  if __name__ == "__main__":
+     current_settings = os.getenv("DJANGO_SETTINGS_MODULE", None)
+ 
+     if not current_settings:
+         raise Exception(
+             "Please configure your .env file along-side manage.py file and "
+             "set 'DJANGO_SETTINGS_MODULE=OIPA.settings_file' variable there!"
+         )
+ 
-     os.environ.setdefault("DJANGO_SETTINGS_MODULE", "OIPA.settings")
+     os.environ.setdefault("DJANGO_SETTINGS_MODULE", current_settings)
  
      from django.core.management import execute_from_command_line
  
      execute_from_command_line(sys.argv)
  
Load current settings from .env file
## Code Before:
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "OIPA.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

## Instruction:
Load current settings from .env file
## Code After:
import os
import sys

from dotenv import find_dotenv, load_dotenv

load_dotenv(find_dotenv())

if __name__ == "__main__":
    current_settings = os.getenv("DJANGO_SETTINGS_MODULE", None)

    if not current_settings:
        raise Exception(
            "Please configure your .env file along-side manage.py file and "
            "set 'DJANGO_SETTINGS_MODULE=OIPA.settings_file' variable there!"
        )

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", current_settings)

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
