Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
django_delayed_storage
.gitignore
LICENSE
README.md
requirements.txt
setup.py

README.md

django_delayed_storage

This app allows you to perform file operations in django storage after the transaction is successfully commited.

Requirements

  • Python 2.6/2.7/3.2/3.3 (3.x requires Django >=1.5)
  • Celery (djcelery)

Installation

  1. Install from PyPI: pip install django-delayed-storage.
  2. Add djcelery and django_delayed_storage to INSTALLED_APPS.
  3. Configure your celery broker.
  4. Init the storage as in the example below

Example

models.py code:

    from django.db import models
    from django.core.files.storage import FileSystemStorage
    from django_delayed_storage import DelayHook
    from django.dispatch import receiver
    from django.db.models import signals


    dummy_storage = FileSystemStorage()  # or any other storage
    dummy_storage = DelayHook(dummy_storage)


    class Dummy(models.Model):
        name = models.CharField(max_length=100)
        img = models.ImageField(upload_to='img', storage=dummy_storage)


    @receiver(signals.post_delete, sender=Dummy)
    def delete_file(signal, sender, instance, **kwargs):
        instance.img.delete(save=False)
Something went wrong with that request. Please try again.