No project description provided
Project description
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 | :x: | :x: | :x: | :x: |
1.11 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
2.2 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
3.0 | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-multitype-file-field-0.0.6.tar.gz
.
File metadata
- Download URL: django-multitype-file-field-0.0.6.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9884181786648e7c1aab4ca085e7ff1b31b5ee2e93adf6d31e7705ed03b868a3 |
|
MD5 | f261e8f70e467f5b2f2fa071187e21db |
|
BLAKE2b-256 | b71b29eb662de44e97cb2c4066b4761af5036a241c01b4db52e7ed1934beba9c |
File details
Details for the file django_multitype_file_field-0.0.6-py2.py3-none-any.whl
.
File metadata
- Download URL: django_multitype_file_field-0.0.6-py2.py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 2, Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cefae2fd0aefeda9fc979bb276001451beebe8d1077dbeaa0d67df4705fac5f |
|
MD5 | c7700722bcd677ed12cc83910559e643 |
|
BLAKE2b-256 | 51bc5e053fd82180f88e59c98f520b85d614b82abca7d2699434135ff2835e7b |