mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-14 15:57:07 +00:00
151 lines
3.9 KiB
Python
Executable file
151 lines
3.9 KiB
Python
Executable file
# Production settings
|
|
import os
|
|
from unipath import Path
|
|
|
|
PROJECT_ROOT = Path(__file__).ancestor(2)
|
|
|
|
DEBUG = False
|
|
|
|
TEMPLATE_DEBUG = DEBUG
|
|
|
|
ADMINS = (
|
|
os.environ.get("ADMINS", "Paul Hallett,paulandrewhallett@gmail.com").split(","),
|
|
)
|
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
|
|
|
MANAGERS = ADMINS
|
|
|
|
BASE_URL = os.environ.get("BASE_URL", "http://pokeapi.co")
|
|
|
|
# Hosts/domain names that are valid for this site; required if DEBUG is False
|
|
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
|
|
ALLOWED_HOSTS = [
|
|
os.environ.get("ALLOWED_HOSTS", ".pokeapi.co"),
|
|
"localhost",
|
|
"127.0.0.1",
|
|
]
|
|
|
|
TIME_ZONE = os.environ.get("TIME_ZONE", "Europe/London")
|
|
|
|
LANGUAGE_CODE = os.environ.get("LANGUAGE_CODE", "en-gb")
|
|
|
|
SITE_ID = 1
|
|
|
|
# If you set this to False, Django will make some optimizations so as not
|
|
# to load the internationalization machinery.
|
|
USE_I18N = True
|
|
|
|
# If you set this to False, Django will not format dates, numbers and
|
|
# calendars according to the current locale.
|
|
USE_L10N = True
|
|
|
|
# If you set this to False, Django will not use timezone-aware datetimes.
|
|
USE_TZ = True
|
|
|
|
# Explicitly define test runner to avoid warning messages on test execution
|
|
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
|
|
|
MIDDLEWARE = [
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "config.urls"
|
|
|
|
WSGI_APPLICATION = "config.wsgi.application"
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
|
"NAME": "pokeapi_co_db",
|
|
"USER": "root",
|
|
"PASSWORD": "pokeapi",
|
|
"HOST": "localhost",
|
|
"PORT": "",
|
|
"CONN_MAX_AGE": 30,
|
|
}
|
|
}
|
|
|
|
CACHES = {
|
|
"default": {
|
|
"BACKEND": "django_redis.cache.RedisCache",
|
|
"LOCATION": "redis://127.0.0.1:6379/1",
|
|
"OPTIONS": {
|
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
|
},
|
|
}
|
|
}
|
|
|
|
SECRET_KEY = os.environ.get(
|
|
"SECRET_KEY", "ubx+22!jbo(^x2_scm-o$*py3e@-awu-n^hipkm%2l$sw$&2l#"
|
|
)
|
|
|
|
CUSTOM_APPS = ("pokemon_v2",)
|
|
|
|
INSTALLED_APPS = (
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.sites",
|
|
"django.contrib.admin",
|
|
"django.contrib.messages",
|
|
"django.contrib.humanize",
|
|
"corsheaders",
|
|
"rest_framework",
|
|
"cachalot",
|
|
'drf_spectacular',
|
|
) + CUSTOM_APPS
|
|
|
|
|
|
API_LIMIT_PER_PAGE = 1
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
|
|
|
CORS_ALLOW_METHODS = "GET"
|
|
|
|
CORS_URLS_REGEX = r"^/api/.*$"
|
|
|
|
REST_FRAMEWORK = {
|
|
"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",),
|
|
"DEFAULT_PARSER_CLASSES": ("rest_framework.renderers.JSONRenderer",),
|
|
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
|
|
"PAGE_SIZE": 20,
|
|
"PAGINATE_BY": 20,
|
|
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
|
|
}
|
|
|
|
|
|
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",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
|
|
|
SPECTACULAR_SETTINGS = {
|
|
'TITLE': 'pokeapi',
|
|
'DESCRIPTION': 'A RESTful API for Pokémon.',
|
|
'SERVERS': [{'url': 'https://pokeapi.co'}],
|
|
'EXTERNAL_DOCS': {'url': 'https://pokeapi.co/docs/v2'},
|
|
'VERSION': '2.7.0',
|
|
'SERVE_INCLUDE_SCHEMA': False,
|
|
'OAS_VERSION': '3.1.0',
|
|
}
|
|
|