Project for merging different file types, as example easy thumbnail image and unpacking archive in one field
Installation
pip install django-multitype-file-field
or from git
pip install -e git+https://github.com/Apkawa/django-multitype-file-field.git#egg=django-multitype-file-field
Django and python version
| Python Django |
3.5 | 3.6 | 3.7 | 3.8 |
|---|---|---|---|---|
| 1.8 | ❌ | ❌ | ❌ | ❌ |
| 1.11 | ✔️ | ✔️ | ✔️ | ❌ |
| 2.2 | ✔️ | ✔️ | ✔️ | ✔️ |
| 3.0 | ❌ | ✔️ | ✔️ | ✔️ |
Usage
models.py
from django.db import models
from multitype_file_field.fields import MultiTypeFileField
# as example, with easy_thumbnails
from easy_thumbnails.fields import ThumbnailerImageField
class FileModel(models.Model):
file = MultiTypeFileField(upload_to='test_archive',
fields={
None: models.FileField, # Fallback
'image/svg+xml': models.FileField, # high priority,
'image': (
ThumbnailerImageField,
dict(resize_source=dict(size=(100, 100), sharpen=True, crop='smart'))
), # tuple, Field and args
}
)
Usage:
from tests.models import TestModel
from django.core.files.base import ContentFile
model = TestModel()
model.file # => <FieldFile: None>
model.file = ContentFile('', name='example.png')
model.file # => <ImageFieldFile: example.png>
model.file = ContentFile('', name='example.txt')
model.file # => <FieldFile: example.txt>
Contributing
run example app
pip install -r requirements-dev.txt
./test/manage.py migrate
./test/manage.py runserver
run tests
pip install -r requirements-dev.txt
pytest
tox
Update version
python setup.py bumpversion
publish pypi
python setup.py publish
Metadata
Release files for django-multitype-file-field 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-multitype-file-field-0.0.6.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_multitype_file_field-0.0.6-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / django-multitype-file-field-0.0.6.tar.gz
| Download URL | django-multitype-file-field-0.0.6.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9884181786648e7c1aab4ca085e7ff1b31b5ee2e93adf6d31e7705ed03b868a3
|
|
BLAKE2b-256 checksum How to use checksums |
b71b29eb662de44e97cb2c4066b4761af5036a241c01b4db52e7ed1934beba9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
|
Release files / django_multitype_file_field-0.0.6-py2.py3-none-any.whl
| Download URL | django_multitype_file_field-0.0.6-py2.py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6cefae2fd0aefeda9fc979bb276001451beebe8d1077dbeaa0d67df4705fac5f
|
|
BLAKE2b-256 checksum How to use checksums |
51bc5e053fd82180f88e59c98f520b85d614b82abca7d2699434135ff2835e7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
|