Skip to main content

Build Status Coverage PyPI Version Python Versions License

django-media-fixtures

Simple project to copy media files (intended for fixtures loads), pretty much as staticfiles 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

pip install django-media-fixtures==1.0.0

Then, put ‘django_media_fixtures’ on your INSTALLED_APPS (on settings.py), just below ‘django.contrib.staticfiles’.

Usage

Just call manage command ‘collectmedia’, same as you do with collectstatic:

python manage.py collectmedia

And then all files on ‘media_fixtures’ folder in-apps will be copied to your MEDIA_ROOT.

So, when you create your fixture (for any ways, even through shell), put your file path matching the same tree folder view as your media file.

For instance,

YourModel.objects.get_or_create(image="uploads/yourmodel/img/example.jpg")

Where the file ‘example.jpg’ is on: yourappfolder/media_fixtures/uploads/yourmodel/img/example.jpg

Configurations

  • MEDIA_FIXTURE_FOLDERNAME

    You can change the media fixtures folder’s name on your apps, just putting this variable on settings.py.

    MEDIA_FIXTURE_FOLDERNAME='my_media_fixtures_folder'
  • MEDIA_FIXTURES_FILES_FINDERS

    You can change the media fixtures finders, to search media files on other folders not in-app, for instance.

    MEDIA_FIXTURES_FILES_FINDERS = (
            'django_media_fixtures.finders.FileSystemFinder',      # combined with MEDIA_FIXTURES_FILES_DIRS, choose specific folders
            'django_media_fixtures.finders.AppDirectoriesFinder',  # default (if you do not set MEDIA_FIXTURES_FILES_FINDERS)
    )
  • MEDIA_FIXTURES_FILES_DIRS

    You can list specific media folders that you want to include on search.

    MEDIA_FIXTURES_FILES_DIRS = [
        "/home/user/myproject/mediafiles",
        "/opt/webfiles/common/",
    ]

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-media-fixtures-1.0.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_media_fixtures-1.0.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file django-media-fixtures-1.0.0.tar.gz.

File metadata

  • Download URL: django-media-fixtures-1.0.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for django-media-fixtures-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f32971ed533e8d36cf8dc6d3f985d18fe9a3639a26a3b5a806a39aecd6f84c05
MD5 4ab438d808e5617dc93f064d5e5c7653
BLAKE2b-256 55fff0f41d726444090b9fcd5f3eaa2af839f788b82e65d01767b75925dca8c5

See more details on using hashes here.

File details

Details for the file django_media_fixtures-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_media_fixtures-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for django_media_fixtures-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c600de39e51e7cb4a38fe5d926f306dc6ce8cf7613dcf3ae80d7784477ff9eeb
MD5 5a84e73bc21716f19bd06e99aebb886c
BLAKE2b-256 7e85deb2d0a007aae45ecc8136e6676092c578766a632690d7f5e086dcd3774c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.1.0

2 files

0.0.3

1 file

0.0.2

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page