diff --git a/blog/__init__.py b/blog/__init__.py index e69de29..aa60bed 100644 --- a/blog/__init__.py +++ b/blog/__init__.py @@ -0,0 +1,3 @@ +import pymysql + +pymysql.install_as_MySQLdb() \ No newline at end of file diff --git a/myblog/__pycache__/settings.cpython-310.pyc b/myblog/__pycache__/settings.cpython-310.pyc index 5f35299..de887ba 100644 Binary files a/myblog/__pycache__/settings.cpython-310.pyc and b/myblog/__pycache__/settings.cpython-310.pyc differ diff --git a/myblog/settings.py b/myblog/settings.py index 683cad2..9df7ea8 100644 --- a/myblog/settings.py +++ b/myblog/settings.py @@ -11,8 +11,21 @@ https://docs.djangoproject.com/en/4.2/ref/settings/ """ from pathlib import Path +from distutils.util import strtobool import os +# Get ENV vars + +def get_env_variable(variable_name, default=None): + for key, value in os.environ.items(): + if key.upper() == variable_name.upper(): + return value + return default + +variable_name = 'DEBUG' +debug_value = get_env_variable(variable_name, default='True') +debug = bool(strtobool(debug_value)) + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -25,9 +38,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = 'django-insecure-u260h434jemg53tn^bd&%x^h9p09^kbkk!2%3t^8%kd0nt^xjf' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = debug -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['*'] # Application definition @@ -76,7 +89,28 @@ WSGI_APPLICATION = 'myblog.wsgi.application' # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases -DATABASES = { + +ENGINE = get_env_variable('ENGINE', default='') +NAME = get_env_variable('NAME', default='') +USER = get_env_variable('USER', default='') +PASSWORD = get_env_variable('PASSWORD', default='') +HOST = get_env_variable('HOST', default='') +PORT = get_env_variable('PORT', default='') + + +if all([ENGINE, NAME, USER, PASSWORD, HOST, PORT]): + DATABASES = { + 'default': { + 'ENGINE': ENGINE, + 'NAME': NAME, + 'USER': USER, + 'PASSWORD': PASSWORD, + 'HOST': HOST, + 'PORT': PORT, + } + } +else: + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..2701ddf --- /dev/null +++ b/readme.md @@ -0,0 +1,9 @@ +# ENV +DEBUG - set django in DEBUG mode + + +# Build Container +docker build -t prudellic:1.0.0 . + +# Start venv +. /venv/bin/activate \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2b45082..ac1bbd6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ asgiref==3.7.2 Django==4.2.7 sqlparse==0.4.4 typing_extensions==4.9.0 +PyMySQL==1.1.0 +cryptography==42.0.1 \ No newline at end of file diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..73364ac --- /dev/null +++ b/setup.sh @@ -0,0 +1,6 @@ +export ENGINE="django.db.backends.mysql" +export NAME="prudellic" +export USER="prudellic" +export PASSWORD="cilledurp321" +export HOST="192.168.30.1" +export PORT="3306"