mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 01:26:57 +03:00
Add a default for REDIS_URL and add it as a variable to the settings
This commit is contained in:
parent
4709a30bd7
commit
8bf9a8c278
|
@ -282,6 +282,8 @@ LOGGING = {
|
||||||
"root": {"level": "INFO", "handlers": ["console"]},
|
"root": {"level": "INFO", "handlers": ["console"]},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REDIS_URL = env("REDIS_URL", default="redis://{% if cookiecutter.use_docker == 'y' %}redis{%else%}localhost{% endif %}:6379/0")
|
||||||
|
|
||||||
{% if cookiecutter.use_celery == 'y' -%}
|
{% if cookiecutter.use_celery == 'y' -%}
|
||||||
# Celery
|
# Celery
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -289,9 +291,9 @@ if USE_TZ:
|
||||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-timezone
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-timezone
|
||||||
CELERY_TIMEZONE = TIME_ZONE
|
CELERY_TIMEZONE = TIME_ZONE
|
||||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url
|
||||||
CELERY_BROKER_URL = env("REDIS_URL")
|
CELERY_BROKER_URL = REDIS_URL
|
||||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
CELERY_RESULT_BACKEND = REDIS_URL
|
||||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended
|
||||||
CELERY_RESULT_EXTENDED = True
|
CELERY_RESULT_EXTENDED = True
|
||||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry
|
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry
|
||||||
|
|
|
@ -16,6 +16,7 @@ from sentry_sdk.integrations.redis import RedisIntegration
|
||||||
from .base import * # noqa: F403
|
from .base import * # noqa: F403
|
||||||
from .base import DATABASES
|
from .base import DATABASES
|
||||||
from .base import INSTALLED_APPS
|
from .base import INSTALLED_APPS
|
||||||
|
from .base import REDIS_URL
|
||||||
{%- if cookiecutter.use_drf == "y" %}
|
{%- if cookiecutter.use_drf == "y" %}
|
||||||
from .base import SPECTACULAR_SETTINGS
|
from .base import SPECTACULAR_SETTINGS
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -37,7 +38,7 @@ DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60)
|
||||||
CACHES = {
|
CACHES = {
|
||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "django_redis.cache.RedisCache",
|
"BACKEND": "django_redis.cache.RedisCache",
|
||||||
"LOCATION": env("REDIS_URL"),
|
"LOCATION": REDIS_URL,
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||||
# Mimicing memcache behavior.
|
# Mimicing memcache behavior.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user