Necesitaba un ratelimit que estuviera disponible en todos los workers, cosa que aparentemente la libreria que estaba usando no tomaba en cuenta asi que la mejor idea que tuve es aprovechar el cache y usarlo para generar el ratelimit :3 asi que como todos los workers se comunican con el mismo cache, todos van a compartir el mismo lock
177 lines
4.2 KiB
Python
177 lines
4.2 KiB
Python
"""
|
|
Base settings for the project
|
|
"""
|
|
import os
|
|
|
|
DEBUG = True
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
SECRET_KEY = 'nyan'
|
|
|
|
"""Hosts allowed to run the server"""
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
"""Django CORS Configuration"""
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
|
CORS_ORIGIN_WHITELIST = []
|
|
|
|
|
|
"""Apps to be run"""
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
|
|
'oauth2_provider',
|
|
'corsheaders',
|
|
'rest_framework',
|
|
'django_rq',
|
|
|
|
'fetcher.apps.FetcherConfig',
|
|
'users.apps.UsersConfig',
|
|
'welcome.apps.WelcomeConfig',
|
|
]
|
|
|
|
"""Middlewares on every call"""
|
|
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',
|
|
]
|
|
|
|
"""Root import path to urlconf"""
|
|
ROOT_URLCONF = 'musiclist.urls'
|
|
|
|
"""How django process templates"""
|
|
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',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
"""Import path to wsgi app to be run"""
|
|
WSGI_APPLICATION = 'musiclist.wsgi.application'
|
|
|
|
"""Database configuration"""
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
}
|
|
}
|
|
|
|
"""Cache configuration"""
|
|
CACHES = {
|
|
"default": {
|
|
"BACKEND": "django_redis.cache.RedisCache",
|
|
"LOCATION": "redis://127.0.0.1:6379/1",
|
|
"OPTIONS": {
|
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
|
},
|
|
"KEY_PREFIX": "DJANGO_SERVER"
|
|
}
|
|
}
|
|
|
|
RQ_QUEUES = {
|
|
'high': {
|
|
'USE_REDIS_CACHE': 'default',
|
|
},
|
|
'default': {
|
|
'USE_REDIS_CACHE': 'default',
|
|
},
|
|
'low': {
|
|
'USE_REDIS_CACHE': 'default',
|
|
},
|
|
}
|
|
|
|
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
|
SESSION_CACHE_ALIAS = "default"
|
|
|
|
"""How to validate password security"""
|
|
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',
|
|
},
|
|
]
|
|
|
|
"""Rest framework configuration"""
|
|
REST_FRAMEWORK = {
|
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
|
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
|
|
),
|
|
'DEFAULT_PERMISSION_CLASSES': (
|
|
'rest_framework.permissions.AllowAny',
|
|
)
|
|
}
|
|
|
|
"""Location settings"""
|
|
LANGUAGE_CODE = 'es-es'
|
|
TIME_ZONE = 'America/Santiago'
|
|
USE_I18N = True
|
|
USE_L10N = True
|
|
USE_TZ = True
|
|
|
|
"""URL where static files can be queried"""
|
|
STATIC_URL = '/static/'
|
|
|
|
"""Absolute path where collectstatic will dump files"""
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
|
|
|
"""Logging configuration"""
|
|
LOGGING = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'formatters': {
|
|
'base': {'format': '[{levelname}]({asctime})({name}): {message}', 'style': '{'}
|
|
|
|
},
|
|
'handlers': {
|
|
'console': {
|
|
'class': 'logging.StreamHandler',
|
|
'formatter': 'base'
|
|
},
|
|
},
|
|
'root': {
|
|
'handlers': ['console'],
|
|
'level': 'DEBUG',
|
|
},
|
|
}
|
|
|
|
"""Cache used for musicbrainz queries"""
|
|
CUSTOM_CACHE = {
|
|
'enabled': True
|
|
}
|
|
|
|
"""Where the login route is defined"""
|
|
LOGIN_URL = '/auth/login/'
|
|
|
|
"""What is the user model of the app"""
|
|
AUTH_USER_MODEL = 'users.User'
|