diff --git a/.gitignore b/.gitignore index 1f6e711..44c83b6 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ docs/_build/ # sandbox sandbox +tests/media diff --git a/README.md b/README.md index 849f83f..0060a71 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # 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 model with `FileField` or `ImageField` fields or their inheritances). +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 1. Install ``django-unused-media``: ``` pip install django-unused-media ``` - Python 2.7, 3.3, 3.4, PyPy are supported
- Django 1.6, 1.7, 1.8 are supported + 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. 2. Add ``django-unused-media`` to ``INSTALLED_APPS``: ```python @@ -21,17 +22,29 @@ This package provides management command `cleanup_unused_media` for Django appli # Usage -For cleanup all unused media, run: +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. -By default command runs in interactive mode. And before removing list of files will be displayed. User should confirm action. -If you would like to use this command in non interactive mode, please use option `--noinput`: +### 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