Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 7d6fb3d

Browse files
committed
run command on app startup
1 parent 9248cd2 commit 7d6fb3d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

core/apps.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
1+
import logging
2+
13
from django.apps import AppConfig
4+
from django.core.management import call_command
25
from shared.helpers.cache import RedisBackend
36

47
from services.redis_configuration import get_redis_connection
58
from utils.cache import cache
69
from utils.config import RUN_ENV
710

11+
logger = logging.getLogger(__name__)
12+
813

914
class CoreConfig(AppConfig):
1015
name = "core"
1116

1217
def ready(self):
1318
import core.signals # noqa: F401
1419

20+
try:
21+
# Call your management command here
22+
call_command(
23+
"insert_data_to_db_from_csv",
24+
"core/management/commands/codecovTiers-Jan25.csv",
25+
"--model",
26+
"tiers",
27+
)
28+
call_command(
29+
"insert_data_to_db_from_csv",
30+
"core/management/commands/codecovPlans-Jan25.csv",
31+
"--model",
32+
"plans",
33+
)
34+
except Exception as e:
35+
logger.error(f"Failed to run startup command: {e}")
36+
1537
if RUN_ENV not in ["DEV", "TESTING"]:
1638
cache_backend = RedisBackend(get_redis_connection())
1739
cache.configure(cache_backend)

0 commit comments

Comments
 (0)