mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-19 12:41:12 +00:00
Also listen to post_delete instead of pre_delete when deleting a document
This commit is contained in:
parent
722ea1d3d8
commit
e0815f7473
1 changed files with 3 additions and 3 deletions
|
|
@ -6,7 +6,7 @@ from django.conf import settings
|
|||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.db.models.signals import pre_delete
|
||||
from django.db.models.signals import post_delete
|
||||
from django.dispatch import Signal
|
||||
from django.dispatch.dispatcher import receiver
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
|
@ -110,8 +110,8 @@ def get_document_model():
|
|||
return document_model
|
||||
|
||||
|
||||
# Receive the pre_delete signal and delete the file associated with the model instance.
|
||||
@receiver(pre_delete, sender=Document)
|
||||
# Receive the post_delete signal and delete the file associated with the model instance.
|
||||
@receiver(post_delete, sender=Document)
|
||||
def document_delete(sender, instance, **kwargs):
|
||||
# Pass false so FileField doesn't save the model.
|
||||
instance.file.delete(False)
|
||||
|
|
|
|||
Loading…
Reference in a new issue