Add production envrionmennt

This commit is contained in:
Dana Lambert 2021-11-16 17:30:40 +13:00
parent 627816a3cd
commit 65bed425cf
11 changed files with 141 additions and 50 deletions

View file

@ -16,17 +16,19 @@ from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_URL = os.getenv("BASE_URL", "localhost:8000")
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-5t05qc2&14xuot4lgs#z0ll9(nn-=3-8yks!u(5ce704t&m_*q'
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", 'django-insecure-5t05qc2&14xuot4lgs#z0ll9(nn-=3-8yks!u(5ce704t&m_*q')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = os.getenv('DJANGO_DEBUG_MODE', '') != 'False'
ALLOWED_HOSTS = []
# os.getenv("ALLOWED_HOSTS", "").split(","),
ALLOWED_HOSTS = (BASE_URL,)
# Application definition
@ -85,9 +87,9 @@ DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'right_tree',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': 'postgres',
'USER': os.getenv("POSTGRES_DB", "postgres"),
'PASSWORD': os.getenv("POSTGRES_USER", "postgres"),
'HOST': os.getenv("POSTGRES_PASSWORD", "postgres"),
'PORT': 5432,
}
}
@ -129,7 +131,9 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_URL = '/staticfiles/'
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'staticfiles')
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

View file

@ -30,6 +30,6 @@ router.register(r'download/csv', views.CSVDownloadView ,basename='downloadcsv')
urlpatterns = [
path('admin/', admin.site.urls),
path('', include(router.urls)),
path('api/', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]