Skip to content

Commit 00c596f

Browse files
committed
Avoid exports in AppConfig when running management commands
1 parent 0cd21c6 commit 00c596f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

django_prometheus/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.apps import AppConfig
22
from django.conf import settings
3+
import sys
34

45
import django_prometheus
56
from django_prometheus.exports import SetupPrometheusExportsFromConfig
@@ -19,6 +20,10 @@ def ready(self):
1920
which shouldn't be done for real monitoring (since these jobs
2021
are usually short-lived), but can be useful for debugging.
2122
"""
23+
if "manage.py" in sys.argv[0] or "django-admin" in sys.argv:
24+
# Avoid exports when running management commands
25+
return
26+
2227
SetupPrometheusExportsFromConfig()
2328
if getattr(settings, "PROMETHEUS_EXPORT_MIGRATIONS", False):
2429
ExportMigrations()

0 commit comments

Comments
 (0)