194 lines
5.1 KiB
Python
Executable file
194 lines
5.1 KiB
Python
Executable file
"""
|
|
Django settings for plant_catalog project.
|
|
|
|
Generated by 'django-admin startproject' using Django 5.0.8.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/5.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/5.0/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import logging
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = 'django-insecure-(e9sx(r=75hv%xni#rcm4)0&67c34+her^!%7dqlghem1=l0lc'
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = False
|
|
|
|
ALLOWED_HOSTS = ['gonzalohd.eu', 'plantsapi.gonzalohd.eu', 'localhost', '192.168.1.139', '127.0.0.1']
|
|
# ALLOWED_HOSTS = ['*']
|
|
|
|
|
|
CSRF_TRUSTED_ORIGINS = [
|
|
"https://succulentspectrum.gonzalohd.eu",
|
|
]
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'rest_framework',
|
|
'catalog',
|
|
'corsheaders',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
CORS_ALLOW_ALL_ORIGINS = True # Allow all origins for development
|
|
|
|
ROOT_URLCONF = 'plant_catalog.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [],
|
|
'APP_DIRS': True,
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_RENDERER_CLASSES': (
|
|
'rest_framework.renderers.JSONRenderer',
|
|
'rest_framework.renderers.BrowsableAPIRenderer', # Enable browsable API
|
|
),
|
|
'DEFAULT_PARSER_CLASSES': (
|
|
'rest_framework.parsers.JSONParser',
|
|
),
|
|
}
|
|
|
|
WSGI_APPLICATION = 'plant_catalog.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
'NAME': 'plant_catalog_db',
|
|
'USER': 'catalog_user',
|
|
'PASSWORD': 'secure_password',
|
|
'HOST': 'localhost',
|
|
'PORT': '3306',
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
},
|
|
]
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/5.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
|
|
|
STATIC_URL = '/static/' # This URL will be used in HTML to load static assets
|
|
# STATIC_ROOT = '/var/www/simple-plant-archive-django/staticfiles' # Path where collectstatic will store files
|
|
STATIC_ROOT = os.path.join(BASE_DIR.parent, 'staticfiles') # or any other directory
|
|
|
|
# Remove or comment out STATICFILES_DIRS in production
|
|
# STATICFILES_DIRS = [
|
|
# os.path.join(BASE_DIR, 'static'),
|
|
# ]
|
|
|
|
# Media files (Uploaded content)
|
|
|
|
MEDIA_URL = '/media/'# Base URL for media files
|
|
# MEDIA_ROOT = '/var/www/simple-plant-archive-django/media'
|
|
MEDIA_ROOT = os.path.join(BASE_DIR.parent, 'media') # Path to store uploaded files
|
|
# MEDIA_ROOT = '/var/www/simple-plant-archive-django/media'
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
import os
|
|
|
|
LOGGING = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'handlers': {
|
|
'file': {
|
|
'level': 'ERROR', # You can set this to 'DEBUG' for more verbose output
|
|
'class': 'logging.FileHandler',
|
|
'filename': os.path.join(BASE_DIR, 'django_error.log'),
|
|
},
|
|
},
|
|
'loggers': {
|
|
'django': {
|
|
'handlers': ['file'],
|
|
'level': 'ERROR', # Match this level to the handler level
|
|
'propagate': True,
|
|
},
|
|
},
|
|
}
|
|
|
|
|
|
|
|
USE_X_FORWARDED_HOST = True
|