All Projects → akolpakov → Django Unused Media

akolpakov / Django Unused Media

Licence: mit
Remove unused media files from Django project

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Unused Media

Mediacms
MediaCMS is a modern, fully featured open source video and media CMS, written in Python/Django and React, featuring a REST API.
Stars: ✭ 313 (+255.68%)
Mutual labels:  django, media
Python Sparkpost
SparkPost client library for Python
Stars: ✭ 87 (-1.14%)
Mutual labels:  django
Django Fakery
🏭 An easy-to-use implementation of Creation Methods for Django, backed by Faker.
Stars: ✭ 84 (-4.55%)
Mutual labels:  django
Muckrock
MuckRock's source code - Please report bugs, issues and feature requests to [email protected]
Stars: ✭ 86 (-2.27%)
Mutual labels:  django
Django Rules
Awesome Django authorization, without the database
Stars: ✭ 1,255 (+1326.14%)
Mutual labels:  django
Shynet
Modern, privacy-friendly, and detailed web analytics that works without cookies or JS.
Stars: ✭ 1,273 (+1346.59%)
Mutual labels:  django
Drf Datatable Example Server Side
DataTables Example (server-side) - Python Django REST framework
Stars: ✭ 84 (-4.55%)
Mutual labels:  django
Cride Platzi
REST API project used to teach Django on Platzi
Stars: ✭ 88 (+0%)
Mutual labels:  django
Swarfarm
SWARFARM - Assistant website for Summoner's War
Stars: ✭ 87 (-1.14%)
Mutual labels:  django
Django Rest Swagger Docs
Beginners approach to Django Rest Swagger
Stars: ✭ 86 (-2.27%)
Mutual labels:  django
Dpress
A simple blog powered by Django
Stars: ✭ 85 (-3.41%)
Mutual labels:  django
Wagtail Torchbox
Wagtail build of Torchbox.com
Stars: ✭ 84 (-4.55%)
Mutual labels:  django
Ariadne
Ariadne is a Python library for implementing GraphQL servers using schema-first approach.
Stars: ✭ 1,274 (+1347.73%)
Mutual labels:  django
Mezzanine Api
RESTful web API for Mezzanine CMS
Stars: ✭ 84 (-4.55%)
Mutual labels:  django
Docker Django Example
A production ready example Django app that's using Docker and Docker Compose.
Stars: ✭ 86 (-2.27%)
Mutual labels:  django
Embedding Reference Apps
Reference applications for common web frameworks showing how to embed Metabase charts
Stars: ✭ 83 (-5.68%)
Mutual labels:  django
Djurl
Simple yet helpful library for writing Django urls by an easy, short and intuitive way.
Stars: ✭ 85 (-3.41%)
Mutual labels:  django
Pybooks
python books
Stars: ✭ 87 (-1.14%)
Mutual labels:  django
Distributed Multi User Scrapy System With A Web Ui
Django based application that allows creating, deploying and running Scrapy spiders in a distributed manner
Stars: ✭ 88 (+0%)
Mutual labels:  django
Django Mfa2
A Django app that handles MFA, it supports TOTP, U2F, FIDO2 U2F (Webauthn), Email Token and Trusted Devices
Stars: ✭ 88 (+0%)
Mutual labels:  django

Delete unused media files from Django project

build-status-image PyPI

Package provides management command cleanup_unused_media for Django applications.

You can remove all not used media files (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.6, 3.7, pypy are tested with tox.

    Django 1.8, 1.9, 1.10, 1.11, 2.0, 2.1, 2.2, 3.0 are tested with tox.

  2. Add django-unused-media to INSTALLED_APPS:

    INSTALLED_APPS = (
        ...
        'django_unused_media',
        ...
    )
    

Usage

To cleanup all unused media files, run management command:

./manage.py cleanup_unused_media

By default command is running in interactive mode. List of files which are going to be removed will be displayed for confirmation. User has to confirm the action.

Options

--noinput, --no-input

Non interactive mode. Command will remove files without any confirmation from the user. Useful for scripts.

./manage.py cleanup_unused_media --noinput

-e, --exclude

To avoid operating on particular files you can use exclude option.

  • * as any symbol is supported.
  • 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 some 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

--minimum-file-age, seconds

Default = 60 (one minute)

Minimum file age to consider for cleanup. All files younger this age will be skipped.

--remove-empty-dirs

By default script keeps empty dirs in media folder. But with this option all empty directories will be removed after cleaning process automatically.

--dry-run

Dry run without any affect on your data

--verbosity {0,1,2}, -v {0,1,2}

Verbosity level.

  • 0 - silent
  • 1 - normal output (default)
  • 2 - verbose output (list individual files)

Tests

At first make sure that you are in virtualenv if you use it.

Install all dependencies:

make setup

To run tests:

make test

To run static analyser:

make flake8

License

MIT licence

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].