prepare for test deployment
This commit is contained in:
@@ -6,7 +6,7 @@ import sys
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Run administrative tasks."""
|
"""Run administrative tasks."""
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'one_trip_api.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'one_trip_api.settings.dev')
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import os
|
|||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'one_trip_api.settings')
|
settings = 'one_trip_api.settings.dev'
|
||||||
|
if os.getenv("DJANGO_RELEASE", False):
|
||||||
|
settings = 'one_trip_api.settings.release'
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings)
|
||||||
|
|
||||||
|
|
||||||
application = get_asgi_application()
|
application = get_asgi_application()
|
||||||
|
|||||||
0
one_trip_api/one_trip_api/settings/__init__.py
Normal file
0
one_trip_api/one_trip_api/settings/__init__.py
Normal file
@@ -14,26 +14,12 @@ from pathlib import Path
|
|||||||
|
|
||||||
# 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
|
||||||
MEDIA_ROOT = BASE_DIR.joinpath("media")
|
|
||||||
STATIC_URL = "static/"
|
STATIC_URL = "static/"
|
||||||
MEDIA_URL = "/media/"
|
MEDIA_URL = "/media/"
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
|
||||||
SECRET_KEY = 'django-insecure-tz%&(g*jikac%ogq%vaf&%i!6m99q_lshu9g-&sz&bw8x!&zk3'
|
|
||||||
|
|
||||||
AUTH_USER_MODEL = 'users.User'
|
AUTH_USER_MODEL = 'users.User'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ALLOWED_HOSTS = ["192.168.0.16", "127.0.0.1", "localhost"]
|
|
||||||
# CORS_ALLOWED_ORIGINS = ["http://192.168.0.16:8000"]
|
|
||||||
CORS_ALLOW_ALL_ORIGINS = True
|
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
'rest_framework.authentication.TokenAuthentication',
|
||||||
@@ -89,10 +75,6 @@ TEMPLATES = [
|
|||||||
|
|
||||||
WSGI_APPLICATION = 'one_trip_api.wsgi.application'
|
WSGI_APPLICATION = 'one_trip_api.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
@@ -100,10 +82,6 @@ DATABASES = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
@@ -119,10 +97,6 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
|
||||||
# https://docs.djangoproject.com/en/4.1/topics/i18n/
|
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'UTC'
|
||||||
@@ -131,7 +105,4 @@ USE_I18N = True
|
|||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
# Default primary key field type
|
|
||||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
9
one_trip_api/one_trip_api/settings/dev.py
Normal file
9
one_trip_api/one_trip_api/settings/dev.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from one_trip_api.settings.base import *
|
||||||
|
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
SECRET_KEY = 'django-insecure-tz%&(g*jikac%ogq%vaf&%i!6m99q_lshu9g-&sz&bw8x!&zk3'
|
||||||
|
|
||||||
|
MEDIA_ROOT = BASE_DIR.joinpath("media")
|
||||||
|
ALLOWED_HOSTS = ["*"]
|
||||||
|
CORS_ALLOW_ALL_ORIGINS = True
|
||||||
30
one_trip_api/one_trip_api/settings/release.py
Normal file
30
one_trip_api/one_trip_api/settings/release.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
from one_trip_api.settings.base import *
|
||||||
|
import os
|
||||||
|
|
||||||
|
print("USING RELEASE SETTINGS")
|
||||||
|
|
||||||
|
SECRET_KEY = 'django-insecure-tz%&(g*jikac%ogq%vaf&%i!6m99q_lshu9g-&sz&bw8x!&zk3'
|
||||||
|
|
||||||
|
DATA_ROOT = Path("/opt/django/data").resolve()
|
||||||
|
MEDIA_ROOT = DATA_ROOT.joinpath("media/")
|
||||||
|
STATIC_ROOT = DATA_ROOT.joinpath("static/")
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = ["groceries.alaevens.ca"]
|
||||||
|
|
||||||
|
if not MEDIA_ROOT.is_dir():
|
||||||
|
os.makedirs(MEDIA_ROOT.as_posix())
|
||||||
|
|
||||||
|
if not STATIC_ROOT.is_dir():
|
||||||
|
os.makedirs(STATIC_ROOT.as_posix())
|
||||||
|
|
||||||
|
USE_HTTPS = True
|
||||||
|
|
||||||
|
urlPrefixes = ["http://"]
|
||||||
|
CSRF_TRUSTED_ORIGINS = []
|
||||||
|
CORS_ALLOWED_ORIGINS = []
|
||||||
|
if USE_HTTPS:
|
||||||
|
urlPrefixes.append("https://")
|
||||||
|
for host in ALLOWED_HOSTS:
|
||||||
|
for prefix in urlPrefixes:
|
||||||
|
CSRF_TRUSTED_ORIGINS.append(f"{prefix}{host}")
|
||||||
|
CORS_ALLOWED_ORIGINS.append(f"{prefix}{host}")
|
||||||
@@ -11,6 +11,11 @@ import os
|
|||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'one_trip_api.settings')
|
settings = 'one_trip_api.settings.dev'
|
||||||
|
if os.getenv("DJANGO_RELEASE", False):
|
||||||
|
settings = 'one_trip_api.settings.release'
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings)
|
||||||
|
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
|||||||
Reference in New Issue
Block a user