configure env

master
Jerrica Bobadilla 5 years ago
parent be05b7fb81
commit 4591ce8d7d

@ -0,0 +1 @@
SECRET_KEY=putsomesecrethere

@ -9,6 +9,8 @@ verify_ssl = true
django = "*" django = "*"
psycopg2-binary = "*" psycopg2-binary = "*"
django-extensions = "*" django-extensions = "*"
python-dotenv = "*"
dj-database-url = "*"
[requires] [requires]
python_version = "3.8" python_version = "3.8"

18
Pipfile.lock generated

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "787971d93a72d315fb906991a877356e209592be55f6f0fa79f09bc68e93848b" "sha256": "33ea631283b8f623ef5e8f5c404c4bb26e1735f210ae464284563318405b30f3"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@ -24,6 +24,14 @@
"markers": "python_version >= '3.5'", "markers": "python_version >= '3.5'",
"version": "==3.2.10" "version": "==3.2.10"
}, },
"dj-database-url": {
"hashes": [
"sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163",
"sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9"
],
"index": "pypi",
"version": "==0.5.0"
},
"django": { "django": {
"hashes": [ "hashes": [
"sha256:a2127ad0150ec6966655bedf15dbbff9697cc86d61653db2da1afa506c0b04cc", "sha256:a2127ad0150ec6966655bedf15dbbff9697cc86d61653db2da1afa506c0b04cc",
@ -78,6 +86,14 @@
"index": "pypi", "index": "pypi",
"version": "==2.8.6" "version": "==2.8.6"
}, },
"python-dotenv": {
"hashes": [
"sha256:8c10c99a1b25d9a68058a1ad6f90381a62ba68230ca93966882a4dbc3bc9c33d",
"sha256:c10863aee750ad720f4f43436565e4c1698798d763b63234fb5021b6c616e423"
],
"index": "pypi",
"version": "==0.14.0"
},
"pytz": { "pytz": {
"hashes": [ "hashes": [
"sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed", "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed",

@ -10,22 +10,29 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/ https://docs.djangoproject.com/en/3.1/ref/settings/
""" """
import os
import dj_database_url
from pathlib import Path from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'. # .env config
BASE_DIR = Path(__file__).resolve().parent.parent from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/3.1/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 = 'n6&$_khrc&w%r&ufg$qmat915-4uhnoux)-_nttj&-0sxpn#dh' SECRET_KEY = os.environ['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = [] ALLOWED_HOSTS = ['localhost']
# Application definition # Application definition
@ -85,6 +92,9 @@ DATABASES = {
} }
} }
# Updating database when deployed
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)
# Password validation # Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
@ -123,3 +133,4 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.1/howto/static-files/ # https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
Loading…
Cancel
Save