adrianoveiga / django-media-fixtures

Simple project to copy media files (intended for fixtures loads). It's django collectstatic for media files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Coverage PyPI Version Python Versions License

django-media-fixtures

Simple project to copy media files (intended for fixtures loads) to the file storage, pretty much as the django.contrib.staticfiles app does.

Dependencies

  • Python 3.5+
  • Django 1.8+

Note: The version (v1.x.x) dropped support of Python2! If you still need Python2, please check the last version of v0.1.x series

Installation

Then, add the django_media_fixtures app in your settings.INSTALLED_APPS:

Usage

The app provides a management command collectmedia:

This works similarly to collectstatic: finds the media_fixtures subdirectory in the apps directories, and copies those files to the settings.MEDIA_ROOT.

So, when you create your fixture (by any means, even through shell), put your file path matching the same tree folder layout as it should be in the MEDIA_ROOT destination.

For instance:

Where the file example.jpeg is found in yourappfolder/media_fixtures/uploads/yourmodel/img/example.jpeg. The collectmedia management command will copy this file to uploads/yourmodel/img/example.jpeg inside the settings.MEDIA_ROOT directory.

Configurations

About

Simple project to copy media files (intended for fixtures loads). It's django collectstatic for media files.

License:MIT License


Languages

Language:Python 100.0%