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
1. Install ``django-unused-media``:
```
pip install django-unused-media
```
Python 2.7, 3.5, PyPy are tested with tox.
Django 1.6, 1.7, 1.8, 1.9, 1.10 are tested with tox.
2. Add ``django-unused-media`` to ``INSTALLED_APPS``:
```python
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`, `--no-input`
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 -e *.gitignore -e *.png
```
Also you can exclude entire folder or files in that folder (path should be relative to `settings.MEDIA_ROOT`):
```
./manage.py cleanup_unused_media -e path/to/dir/* -e path/to/dir/my*.doc
```
# Tests
At first make sure that you are in virtualenv.
Install all dependencies:
```
make setup
```
To run tests:
```
make test
```
# License
[MIT licence](./LICENSE)
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.5, PyPy are tested with tox.
Django 1.6, 1.7, 1.8, 1.9, 1.10 are tested with tox.
2. Add ``django-unused-media`` to ``INSTALLED_APPS``:
```python
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`, `--no-input`
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 -e *.gitignore -e *.png
```
Also you can exclude entire folder or files in that folder (path should be relative to `settings.MEDIA_ROOT`):
```
./manage.py cleanup_unused_media -e path/to/dir/* -e path/to/dir/my*.doc
```
# Tests
At first make sure that you are in virtualenv.
Install all dependencies:
```
make setup
```
To run tests:
```
make test
```
# License
[MIT licence](./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
File details
Details for the file django-unused-media-0.1.6.tar.gz
.
File metadata
- Download URL: django-unused-media-0.1.6.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
f26334012d72ababd271b20dd5f04b2796c7d40f10489e517b164dfa7670f1dd
|
|
MD5 |
ebad0ff76d1e5037b1845082fa0e0440
|
|
BLAKE2b-256 |
03bcfb880e6abb4eb70eb094f5784668377cc3d4e9e7bfa4f06e8867948f23ac
|