Delete unused media files from Django project
Project description
Delete unused media files from Django project
This package provides management command cleanup_unused_media for Django application. With help of this command you can remove all media files which are no longer used (files without references from any Django model with FileField or ImageField fields or their inheritances).
Installation
Install django-unused-media:
pip install django-unused-media
Python 2.7, 3.3, 3.4, 3.5, PyPy are tested with tox.
Django 1.6, 1.7, 1.8, 1.9 are tested with tox.
Add django-unused-media to INSTALLED_APPS:
INSTALLED_APPS = ( ... 'django_unused_media', ... )
Usage
For cleanup all unused media run management command:
./manage.py cleanup_unused_media
By default command runs in interactive mode. And before removing list of files will be displayed. User should confirm the action.
Options
--noinput
Non interactive mode. Command will remove files without confirmation from user. Useful for scripts.
./manage.py cleanup_unused_media --noinput
-e, --exclude
To avoid operating on files whose names match a particular pattern. Pattern supports only * as any symbols. Can use multiple options in one command.
For example, to keep .gitignore and *.png files you can use:
./manage.py cleanup_unused_media --exclude .gitignore --exclude *.png
Tests
At first make sure that you are in virtualenv.
Install all dependencies:
make setup
To run tests:
make test
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django-unused-media-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0580b446710c1d6489f73fd0e0ec0eb4e6c2c95d520a691bfeb366656e6dc4c2 |
|
MD5 | d3c8e07d037a65249ae3132e23266c68 |
|
BLAKE2b-256 | 111828fbd9640f0dce399d3f1bc5d40661904c626bd6f955a40ac2253db9627a |