Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
default=f"sqlite:///{DB_PATH_SQLITE}",
)
}
# https://docs.djangoproject.com/en/dev/topics/db/transactions/#tying-transactions-to-http-requests
DATABASES["default"]["ATOMIC_REQUESTS"] = True
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

Expand Down
9 changes: 9 additions & 0 deletions config/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
LOGGING["loggers"]["ethicalads_ext"]["level"] = "DEBUG"


# Cache
# https://docs.djangoproject.com/en/dev/topics/cache/
# https://github.com/jazzband/django-redis
# --------------------------------------------------------------------------
# Use the Redis cache in development if the REDIS_URL env var is set
if env("REDIS_URL", default=None):
CACHES["default"] = env.cache("REDIS_URL")


# Celery settings for asynchronous tasks
# http://docs.celeryproject.org
# --------------------------------------------------------------------------
Expand Down
16 changes: 12 additions & 4 deletions config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
# --------------------------------------------------------------------------
DATABASES["default"] = env.db() # Raises ImproperlyConfigured if DATABASE_URL not set
DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=3600)

if "replica" in DATABASES:
DATABASES["replica"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=3600)
for db in ("default", "replica"):
if db in DATABASES:
# Enable database connection pooling
# https://docs.djangoproject.com/en/dev/ref/databases/#connection-pool
if "OPTIONS" not in DATABASES[db]:
DATABASES[db]["OPTIONS"] = {}
if DATABASES[db]["ENGINE"] == "django.db.backends.postgresql":
DATABASES[db]["OPTIONS"]["pool"] = True
else:
# CONN_MAX_AGE should be 0 when using connection pooling
DATABASES[db]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=3600)


# Logging changes
Expand All @@ -56,7 +64,7 @@

# Cache
# https://docs.djangoproject.com/en/dev/topics/cache/
# https://niwinz.github.io/django-redis/
# https://github.com/jazzband/django-redis
# --------------------------------------------------------------------------
CACHES["default"] = env.cache("REDIS_URL")

Expand Down
6 changes: 6 additions & 0 deletions config/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
},
}

# Always use in-memory cache for testing
CACHES["default"] = {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "",
}

# Celery should be always eager - there's no distributed celery workers in test
CELERY_TASK_ALWAYS_EAGER = True

Expand Down
7 changes: 5 additions & 2 deletions requirements/production.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
gunicorn

# Database driver
psycopg2-binary
# https://www.psycopg.org/psycopg3/docs/basic/install.html
psycopg[binary,pool]

# Email sending
django-anymail

# Redis (cache)
django-redis
# Hiredis is a faster Redis client implementation in C
# https://github.com/jazzband/django-redis?tab=readme-ov-file#pluggable-parsers
django-redis[hiredis]

# Upload files to cloud storage (Azure)
django-storages[azure]
Expand Down
77 changes: 42 additions & 35 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.15
aiohttp==3.13.1
# via geoip2
aiosignal==1.4.0
# via aiohttp
amqp==5.3.1
# via kombu
asgiref==3.9.1
asgiref==3.10.0
# via
# django
# django-allauth
Expand All @@ -22,29 +22,29 @@ async-timeout==5.0.1
# via
# aiohttp
# redis
attrs==25.3.0
attrs==25.4.0
# via aiohttp
azure-core==1.35.0
azure-core==1.36.0
# via
# azure-storage-blob
# django-storages
azure-storage-blob==12.26.0
azure-storage-blob==12.27.0
# via django-storages
billiard==4.2.1
billiard==4.2.2
# via celery
bleach==6.2.0
# via -r base.in
celery[redis]==5.5.0rc1
# via -r base.in
certifi==2025.8.3
certifi==2025.10.5
# via
# requests
# sentry-sdk
cffi==1.17.1
cffi==2.0.0
# via cryptography
charset-normalizer==3.4.3
charset-normalizer==3.4.4
# via requests
click==8.2.1
click==8.3.0
# via
# celery
# click-didyoumean
Expand All @@ -58,7 +58,7 @@ click-repl==0.3.0
# via celery
crispy-bootstrap4==2025.6
# via -r base.in
cryptography==45.0.6
cryptography==46.0.3
# via
# azure-storage-blob
# fido2
Expand All @@ -80,11 +80,11 @@ django==5.2.7
# django-storages
# djangorestframework
# jsonfield
django-allauth[mfa]==65.11.0
django-allauth[mfa]==65.12.1
# via -r base.in
django-anymail==13.0.1
django-anymail==13.1
# via -r production.in
django-cors-headers==4.7.0
django-cors-headers==4.9.0
# via -r base.in
django-countries==7.6.1
# via -r base.in
Expand All @@ -100,7 +100,7 @@ django-extensions==4.1
# via -r base.in
django-ratelimit==3.0.1
# via -r base.in
django-redis==6.0.0
django-redis[hiredis]==6.0.0
# via -r production.in
django-simple-history==3.10.1
# via -r base.in
Expand All @@ -114,19 +114,21 @@ djangorestframework-jsonp==1.0.2
# via -r base.in
fido2==2.0.0
# via django-allauth
frozenlist==1.7.0
frozenlist==1.8.0
# via
# aiohttp
# aiosignal
geoip2==5.1.0
# via -r base.in
gunicorn==23.0.0
# via -r production.in
idna==3.10
hiredis==3.3.0
# via redis
idna==3.11
# via
# requests
# yarl
ip2proxy==3.5.1
ip2proxy==3.5.2
# via -r base.in
isodate==0.7.2
# via azure-storage-blob
Expand All @@ -136,27 +138,31 @@ kombu==5.5.4
# via celery
maxminddb==2.8.2
# via geoip2
multidict==6.6.4
multidict==6.7.0
# via
# aiohttp
# yarl
newrelic==10.16.0
newrelic==11.0.1
# via -r production.in
packaging==25.0
# via
# gunicorn
# kombu
pillow==11.3.0
pillow==12.0.0
# via -r base.in
prompt-toolkit==3.0.51
prompt-toolkit==3.0.52
# via click-repl
propcache==0.3.2
propcache==0.4.1
# via
# aiohttp
# yarl
psycopg2-binary==2.9.10
psycopg[binary,pool]==3.2.10
# via -r production.in
pycparser==2.22
psycopg-binary==3.2.10
# via psycopg
psycopg-pool==3.2.6
# via psycopg
pycparser==2.23
# via cffi
pyjwt==2.10.1
# via
Expand All @@ -168,7 +174,7 @@ pytz==2025.2
# via -r base.in
qrcode==8.2
# via django-allauth
redis==5.3.1
redis[hiredis]==5.3.1
# via
# celery
# django-redis
Expand All @@ -179,26 +185,27 @@ requests==2.32.5
# django-slack
# geoip2
# stripe
sentry-sdk==2.35.0
sentry-sdk==2.42.0
# via -r production.in
six==1.17.0
# via
# azure-core
# python-dateutil
# via python-dateutil
sqlparse==0.5.3
# via django
stripe==4.2.0
# via
# -r base.in
# dj-stripe
typing-extensions==4.14.1
typing-extensions==4.15.0
# via
# aiosignal
# asgiref
# azure-core
# azure-storage-blob
# cryptography
# django-countries
# multidict
# psycopg
# psycopg-pool
tzdata==2025.2
# via kombu
ua-parser==1.0.1
Expand All @@ -212,18 +219,18 @@ urllib3==2.5.0
# sentry-sdk
user-agents==2.2.0
# via -r base.in
uuid-utils==0.11.0
uuid-utils==0.11.1
# via -r base.in
vine==5.1.0
# via
# amqp
# celery
# kombu
wcwidth==0.2.13
wcwidth==0.2.14
# via prompt-toolkit
webencodings==0.5.1
# via bleach
whitenoise==6.9.0
whitenoise==6.11.0
# via -r base.in
yarl==1.20.1
yarl==1.22.0
# via aiohttp