From dbaa9c1ce17a9e19f81bc24b4559569f84e3f2c2 Mon Sep 17 00:00:00 2001 From: bctiemann Date: Thu, 12 Dec 2024 08:16:28 -0500 Subject: [PATCH] Fixes: #18021 - Clear Swagger/drf-spectacular API cache on startup (#18174) * Clear Swagger API cache on startup * Clear entire Redis cache on startup if DEBUG=True --- netbox/core/apps.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netbox/core/apps.py b/netbox/core/apps.py index 1dfc7a65e..0811e5cb2 100644 --- a/netbox/core/apps.py +++ b/netbox/core/apps.py @@ -1,4 +1,6 @@ from django.apps import AppConfig +from django.conf import settings +from django.core.cache import cache from django.db import models from django.db.migrations.operations import AlterModelOptions @@ -22,3 +24,7 @@ class CoreConfig(AppConfig): # Register models register_models(*self.get_models()) + + # Clear Redis cache on startup in development mode + if settings.DEBUG: + cache.clear()