Created
June 23, 2010 16:55
-
-
Save codekoala/450194 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from django.core.signals import post_delete | |
| from articles.models import Attachment | |
| def cleanup_filesystem(sender, instance): | |
| """Removes attached files from the filesystem""" | |
| try: | |
| os.unlink(instance.attachment.path) | |
| except OSError: | |
| # file doesn't exist or permissions are incorrect | |
| pass | |
| post_delete.connect(cleanup_filesystem, sender=Attachment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment