问题是–当它相应地接收到post_save或post_delete信号时,是否可以在指定的处理函数中区分情况。我的意思通常是,但不是通过隐性特征(例如存在或缺乏“创造”)来实现。 我可以将2个信号划分为2个处理程序,但是这样会不太方便...
@receiver([post_save, post_delete], sender=Article)
def invalidate_by_Article(sender, instance, **kwargs):
show_by_heading_page_url = reverse('articles:show_by_heading',
args=(instance.foreignkey_to_subheading_id,))
article_content_page_url = reverse("articles:detail",
args=(instance.foreignkey_to_subheading_id, instance.id))
article_resurrection_url = reverse("articles:resurrection")
main_page_url = reverse('articles:articles_main')
urls = [show_by_heading_page_url, article_content_page_url]
if not instance.show:
urls.extend([article_resurrection_url, main_page_url])
if kwargs.get("created"):
urls.append(main_page_url)
list(find_urls(urls, purge=True))