kopia lustrzana https://github.com/wagtail/wagtail
Use page_published signal for cache invalidation instead of post_save
rodzic
71f0ff6506
commit
5709a160e6
|
@ -1,12 +1,13 @@
|
|||
from django.db import models
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
from django.db.models.signals import post_delete
|
||||
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailcore.signals import page_published
|
||||
|
||||
from wagtail.contrib.wagtailfrontendcache.utils import purge_page_from_cache
|
||||
|
||||
|
||||
def post_save_signal_handler(instance, **kwargs):
|
||||
def page_published_signal_handler(instance, **kwargs):
|
||||
purge_page_from_cache(instance)
|
||||
|
||||
|
||||
|
@ -20,5 +21,5 @@ def register_signal_handlers():
|
|||
|
||||
# Loop through list and register signal handlers for each one
|
||||
for model in indexed_models:
|
||||
post_save.connect(post_save_signal_handler, sender=model)
|
||||
page_published.connect(page_published_signal_handler, sender=model)
|
||||
post_delete.connect(post_delete_signal_handler, sender=model)
|
||||
|
|
Ładowanie…
Reference in New Issue