Skip to main content

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

  1. Install this app with pip install wagtailpurge
  2. Add wagtailpurge to your INSTALLED_APPS
  3. 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 existing renditions for a Wagtail image (or 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 for the URL of each rendition, allowing the users to download freshly generated ones.

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

wagtailpurge-0.2.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

wagtailpurge-0.2.0-py2.py3-none-any.whl (18.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file wagtailpurge-0.2.0.tar.gz.

File metadata

  • Download URL: wagtailpurge-0.2.0.tar.gz
  • Upload date:
  • Size: 16.0 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

Hashes for wagtailpurge-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0590f937659ebbac43e5aeffc44434702d5189a207dd752a935594f5674e4088
MD5 dcd2ce7cb0f31c9537f814d435974ce6
BLAKE2b-256 0418a19d87a19fa07cf3a63eea92ab84baa11af8c7c895e0f9823d03be190d9a

See more details on using hashes here.

File details

Details for the file wagtailpurge-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: wagtailpurge-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.1 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

Hashes for wagtailpurge-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 15608d07e2d8414dc66a6f44942f4863b9e4791e1965c63a0aae5ce5a001b1e2
MD5 514b574172441315361dcfd775fb5296
BLAKE2b-256 515c01239a57f536c3453c3d6bc823190e780aad91e041b3032de1af4bb1ee70

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page