No project description provided
Project description
wagtailpurge
Trigger cache purges from within the Wagtail CMS. The app is tested for compatibility with:
- Django >= 3.1
- Wagtail >= 2.12
Get started
- Install this app with
pip install wagtailpurge
- Add
wagtailpurge
to yourINSTALLED_APPS
- Log into Wagtail and look out for the Purge menu item :)
By default, only superusers can submit purge requests, but permissions for individual request types can easily be applied to your existing groups to make the functionality available to others.
What can I purge?
Django caches
Utilizes Django's low-level cache API to clear a cache from your project's CACHES
setting value.
NOTE: This option is only available when CACHES
contains at least one item.
Wagtail page URLs
Utilizes Wagtail's wagtail.contrib.frontend_cache
app to purge selected page URLs from a CDN or upstream cache. You can easily purge sections of the tree by choosing to purge children or descendants of the selected page.
NOTE: This option is only available when wagtail.contrib.frontend_cache
is installed.
Wagtail image renditions
Deletes all previously generated renditions for Wagtail images of your choosing. If the wagtail.contrib.frontend_cache
app is installed, purge requests will also be sent to your CDN or upstream cache, so that freshly generated renditions will be cached instead.
Custom purge requests
If you want to purge something different, it's possible to add your own purge request type. The process is easier than you might think, as everything is defined on the model class. The only requirements are that you use the included BasePurgeRequest
class as a base, and that you add a process()
method to handle the actual 'purging' for each request. Here's an example:
from django.db import models
from django.forms.widgets import RadioSelect
from wagtailcache.models import BasePurgeRequest
from .utils import purge_naughty_monkey
class NaughtinessCategoryChoices(models.TextChoices):
BITING = "biting", "Biting"
SCRATCHING = "scratching", "Scratching"
TOMFOOLERY = "tomfoolery", "General tomfoolery"
class NaughtyMonkeyPurgeRequest(BasePurgeRequest):
# Add custom fields
name = models.CharField(max_length=100)
category = models.CharField(
max_length=30,
choices=NaughtinessCategoryChoices.choices
)
# Add panels to show custom fields in the submit form
panels = (
FieldPanel("name"),
FieldPanel("category", widget=RadioSelect())
)
# Optionally override the menu label and icon
purge_menu_label = "Naughty monkey"
purge_menu_icon = "warning"
# Optionally add columns to the listing
list_display_extra = ["name", "category", "custom_method"]
# Optionally add filter options to the listing
list_filter_extra = ["category"]
def process(self) -> None:
"""
Implemenst 'handling' for this request. The method doesn't need to
return anything, and any exceptions raised here will be logged
automatically.
"""
purge_naughty_monkey(self.name, self.category)
def custom_method(self) -> str:
"""
Include non-field columns in the listing by adding a model
method to return what you need, and include the method name
in `list_display_extra`.
"""
return "Custom value"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wagtailpurge-0.1.1.tar.gz
.
File metadata
- Download URL: wagtailpurge-0.1.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53281f1956e763498849eb91a506e3fdd2b9ac2da2f8602862602dae0e4dd47f |
|
MD5 | 851a0f97d5e1fa8c1a4cfc479536ba1b |
|
BLAKE2b-256 | 8de5d7d58d70bb2c79d987d8e59c464773aacc603928056b5bc48ee8d7e85307 |
File details
Details for the file wagtailpurge-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: wagtailpurge-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db0824d1be2b16a8e1ac205f77a86aac9813d5e6794ad8a2a85d231a241d5d46 |
|
MD5 | 3646a80811b0e6ef74e46c94e6e3de18 |
|
BLAKE2b-256 | 8dbe14e125d5408bd4982620696c720ea4e77286fcf0c155972c9b97652096f7 |