Spaces:
Sleeping
Sleeping
File size: 849 Bytes
58ba040 e50f22e 58ba040 e50f22e 58ba040 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # webapp/apps.py
from django.apps import AppConfig
from django.core.management import call_command
from django.db.utils import OperationalError, ProgrammingError
class WebappConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "webapp"
def ready(self):
"""
Ensure the database cache table exists.
This runs on startup in each process. If the table already exists
or the DB isn't ready yet, we just ignore the error.
"""
try:
call_command("createcachetable", "django_cache", verbosity=0)
except (OperationalError, ProgrammingError):
# Table already exists or DB not ready; safe to ignore
pass
except Exception:
# Any other weird error: ignore as well, we just won't have DB cache
pass
|