Skip to main content

django-cleanup-later

A quick, rough around the edges Django application to remember and remove temporary files.

The purpose of this application is to allow the user to create a temporary file (e.g. for the purpose of streaming or to allow a time limited availability) and automatically remove it after a given period of time.

At present this can be done automatically using the provided middleware, manually by running the cleanup_later management command, or by calling the CleanupFile.cleanup() function directly.

It's been developed and tested on Python 3.7 and Django 2.2 .. your mileage may vary with other configurations.

Installation

Install via pip or download the repository:

pip install django-cleanup-later

Add the app to your INSTALLED_APPS setting:

INSTALLED_APPS = [
        ...
        'cleanup_later',
    ]

Make sure to migrate:

manage.py migrate

And optionally add the middleware if you want files to be removed automatically without the need for a cron or background process:

MIDDLEWARE = [
    ...
    'cleanup_later.middleware.CleanupMiddleware',
]

Note that using the middleware probably isn't the most efficient approach. If your project is using a cron or celery for background processing, it's more efficient to run the cleanup from there.

Usage

To use the app, simply register the filename you would like to later cleanup like so:

from cleanup_later.models import CleanupFile

CleanupFile.register('file_to_delete.txt')

By default, files will be deleted after 10 minutes, but you can override this by specifying a validity parameter as a timedelta .. e.g.

CleanupFile.register('file_to_delete.txt', timedelta(minutes=30))

Simples!

Contributing

Pull requests are welcome if you find this library useful.

Metadata

Release files for django-cleanup-later 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cleanup-later 0.1
File Size Uploaded
django-cleanup-later-0.1.tar.gz 4.0 kB Details

Release files / django-cleanup-later-0.1.tar.gz

Download URL django-cleanup-later-0.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
91fc4ce9ca193d31ff4e47f0558331bdf7e0de3b3fe80ee98f06d6b2a886380e
BLAKE2b-256 checksum
How to use checksums
965279f706736d548416531a1e98ecdfdc310979a1f0eb33f08631c05b22bbbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.19.5 CPython/3.6.7

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page