Add management command to purge caches
This commit is contained in:
parent
8f66feeaa5
commit
04aa301c75
3 changed files with 22 additions and 0 deletions
0
website/contrib/wagtail_cache_purge/__init__.py
Normal file
0
website/contrib/wagtail_cache_purge/__init__.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from argparse import ArgumentParser
|
||||
|
||||
from django.core.cache import DEFAULT_CACHE_ALIAS, caches
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
parser.add_argument(
|
||||
"cache",
|
||||
type=str,
|
||||
default=DEFAULT_CACHE_ALIAS,
|
||||
nargs="?",
|
||||
choices=list(caches),
|
||||
help="Cache alias. Default: %(default)s",
|
||||
)
|
||||
|
||||
def handle(self, *args: list, **options: dict) -> None:
|
||||
cache_alias = options["cache"]
|
||||
self.stdout.write(f"Purging cache {cache_alias}")
|
||||
caches[cache_alias].clear()
|
|
@ -44,6 +44,7 @@ INSTALLED_APPS = [
|
|||
"website.contrib.mermaid_block",
|
||||
"website.contrib.unsplash",
|
||||
"website.contrib.singleton_page",
|
||||
"website.contrib.wagtail_cache_purge",
|
||||
"wagtail.contrib.forms",
|
||||
"wagtail.contrib.redirects",
|
||||
"wagtail.contrib.modeladmin",
|
||||
|
|
Loading…
Reference in a new issue