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.
Hint: This is a fork of the original package which is no longer maintained
Changelog
1.0.1: Include PR to fix Django 4 smart_text exceptions
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.1
Then, add the django_media_fixtures app in your settings.INSTALLED_APPS:
INSTALLED_APPS = [
...,
'django.contrib.staticfiles',
'django_media_fixtures',
...
]
Usage
The app provides a management command collectmedia:
python manage.py 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:
YourModel.objects.get_or_create(image="uploads/yourmodel/img/example.jpeg")
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
- 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/", ]
Metadata
Release files for django-media-fixtures-next 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-media-fixtures-next-1.0.1.tar.gz | 13.9 kB | Without provenance | Details for django-media-fixtures-next-1.0.1.tar.gz |
Release files / django-media-fixtures-next-1.0.1.tar.gz
| Download URL | django-media-fixtures-next-1.0.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
757ee7acae8c40ea18dace583c8469e0db0c3aa124a444c69e9b476630ef1f66
|
|
BLAKE2b-256 checksum How to use checksums |
b71b27a888abd094d2ab53023d6f9626b52a2df7d552ff55bfbc626aea824f8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.5
|
Security for django-media-fixtures-next 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.