From 7b5625a722a9b3e69636ffe3a89b9d314a1ce8e3 Mon Sep 17 00:00:00 2001 From: kkthxbye <> Date: Fri, 29 Apr 2022 09:19:19 +0200 Subject: [PATCH 1/2] Add management command for clearing cache --- netbox/extras/management/commands/clearcache.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 netbox/extras/management/commands/clearcache.py diff --git a/netbox/extras/management/commands/clearcache.py b/netbox/extras/management/commands/clearcache.py new file mode 100644 index 000000000..22843c490 --- /dev/null +++ b/netbox/extras/management/commands/clearcache.py @@ -0,0 +1,11 @@ +from django.core.cache import cache +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): + """Command to clear the entire cache.""" + help = 'Clears the cache.' + + def handle(self, *args, **kwargs): + cache.clear() + self.stdout.write('Cache has been cleared.', ending="\n") From 9f3846ec5f3d9f8fdb0b9758e00d81b0df623989 Mon Sep 17 00:00:00 2001 From: kkthxbye <> Date: Fri, 29 Apr 2022 09:19:37 +0200 Subject: [PATCH 2/2] Clear the cache when running the upgrade script --- upgrade.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/upgrade.sh b/upgrade.sh index 61e6106cd..161d65e32 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -108,6 +108,11 @@ COMMAND="python3 netbox/manage.py clearsessions" echo "Removing expired user sessions ($COMMAND)..." eval $COMMAND || exit 1 +# Clear the cache +COMMAND="python3 netbox/manage.py clearcache" +echo "Clearing the cache ($COMMAND)..." +eval $COMMAND || exit 1 + if [ -v WARN_MISSING_VENV ]; then echo "--------------------------------------------------------------------" echo "WARNING: No existing virtual environment was detected. A new one has"