Commit d3c48f99 authored by Ilya Simonov's avatar Ilya Simonov

fix settings for local start

parent e26ab0a7
...@@ -12,8 +12,10 @@ https://docs.djangoproject.com/en/3.0/ref/settings/ ...@@ -12,8 +12,10 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
import os import os
import environ import environ
import sys
from pathlib import Path from pathlib import Path
from django.core.management.utils import get_random_secret_key
env = environ.Env(DEBUG=(bool, False)) env = environ.Env(DEBUG=(bool, False))
...@@ -21,18 +23,16 @@ env = environ.Env(DEBUG=(bool, False)) ...@@ -21,18 +23,16 @@ env = environ.Env(DEBUG=(bool, False))
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('SECRET_KEY') SECRET_KEY = env('SECRET_KEY', default=get_random_secret_key())
# Take environment variables from .env file # Take environment variables from .env file
environ.Env.read_env(os.path.join(BASE_DIR, '.env')) environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env('DEBUG') DEBUG = env('DEBUG', default=True)
DEVELOPMENT_MODE = env('DEVELOPMENT_MODE', default=True)
ALLOWED_HOSTS = env('ALLOWED_HOSTS', default=[]) ALLOWED_HOSTS = env('ALLOWED_HOSTS', default=[])
...@@ -86,18 +86,26 @@ WSGI_APPLICATION = 'cp_video.wsgi.application' ...@@ -86,18 +86,26 @@ WSGI_APPLICATION = 'cp_video.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases if DEVELOPMENT_MODE is True:
DATABASES = {
# DATABASES = { 'default': {
# 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2',
# 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'cp_video',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'USER': 'django',
# } 'PASSWORD': 'django',
# } 'HOST': '127.0.0.1',
}
DATABASES = { }
'default': env.db('DATABASE_URL', default='postgres://user:pass@postgreshost:5432/dbname'), elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
} if env('DATABASE_URL', default=None) is None:
raise Exception('DATABASE_URL environment variable not defined')
DATABASES = {
'default': env.db(
'DATABASE_URL',
default='postgres://user:pass@postgreshost:5432/dbname'
),
}
# Password validation # Password validation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment