170 lines
4.6 KiB
Python
170 lines
4.6 KiB
Python
import datetime
|
|
|
|
from django.utils.text import gettext_lazy as _
|
|
|
|
from config.settings.environ import * # noqa
|
|
|
|
APP_NAME = 'Shop'
|
|
DESCRIPTION = ''
|
|
VERSION = '0.1.0'
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = DEBUG
|
|
|
|
if not DEBUG:
|
|
import socket
|
|
|
|
ALLOWED_HOSTS.append(socket.gethostbyname(socket.gethostname()))
|
|
|
|
|
|
DJANGO_APPS = [
|
|
'unfold', # before django.contrib.admin
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
]
|
|
|
|
THIRD_PARTY_APPS = [
|
|
'corsheaders',
|
|
'django_extensions',
|
|
'django_filters',
|
|
'watchman',
|
|
'drf_spectacular',
|
|
'gonk',
|
|
'rest_framework_simplejwt',
|
|
]
|
|
|
|
PROJECT_APPS = ['shop', 'users', 'web']
|
|
|
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + PROJECT_APPS
|
|
|
|
|
|
if DEBUG:
|
|
INSTALLED_APPS += ['django_browser_reload']
|
|
|
|
PROJECT_MIDDLEWARE = []
|
|
|
|
DJANGO_MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
MIDDLEWARE = DJANGO_MIDDLEWARE + PROJECT_MIDDLEWARE
|
|
|
|
if DEBUG:
|
|
INSTALLED_APPS += ['silk']
|
|
MIDDLEWARE += ['silk.middleware.SilkyMiddleware', 'django_browser_reload.middleware.BrowserReloadMiddleware']
|
|
|
|
ROOT_URLCONF = 'config.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',
|
|
'web.context_processors.web_settings',
|
|
]
|
|
},
|
|
}
|
|
]
|
|
|
|
WSGI_APPLICATION = 'config.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
|
|
|
DATABASES = {'default': DATABASE_URL}
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/5.1/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.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'es'
|
|
|
|
LANGUAGES = (('en', _('Inglés')), ('es', _('Castellano')))
|
|
|
|
TIME_ZONE = 'Europe/Madrid'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/5.1/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
STATIC_ROOT = BASE_DIR / 'static'
|
|
|
|
MEDIA_URL = '/media/'
|
|
MEDIA_ROOT = BASE_DIR / 'media'
|
|
|
|
LOGIN_REDIRECT_URL = '/login/'
|
|
|
|
STORAGES = {
|
|
'default': {'BACKEND': 'django.core.files.storage.FileSystemStorage'},
|
|
'staticfiles': {'BACKEND': 'whitenoise.storage.CompressedManifestStaticFilesStorage'},
|
|
}
|
|
|
|
|
|
# Django Rest Framework Configuration
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),
|
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
|
'rest_framework.authentication.SessionAuthentication',
|
|
'rest_framework.authentication.BasicAuthentication',
|
|
),
|
|
'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',),
|
|
'DEFAULT_FILTER_BACKENDS': [
|
|
'rest_framework.filters.OrderingFilter',
|
|
'django_filters.rest_framework.DjangoFilterBackend',
|
|
'rest_framework.filters.SearchFilter',
|
|
],
|
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
|
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
|
|
'PAGE_SIZE': PAGE_SIZE,
|
|
}
|
|
|
|
LOCALE_PATHS = [BASE_DIR / 'locale']
|
|
|
|
if S3_ENABLED:
|
|
STORAGES['default'] = {'BACKEND': 'storages.backends.s3boto3.S3Boto3Storage'}
|
|
|
|
WATCHMAN_STORAGE_PATH = 'tmp'
|
|
|
|
EMAIL_USE_TLS = True
|
|
EMAIL_USE_SSL = False
|
|
|
|
CELERY_BROKER_URL = env.str('CELERY_BROKER_URL', default='memory://localhost:8000//')
|
|
CELERY_TIME_ZONE = TIME_ZONE
|
|
CELERY_ALWAYS_EAGER = DEBUG
|