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.txt
./test/manage.py migrate
./test/manage.py runserver
run tests
pip install -r requirements.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
Close
Hashes for django-multitype-file-field-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdf7b3d4d161f6075be9b22223c44b6339ddd1ca397f56897443a9d3787d3220 |
|
MD5 | 894688a4f6d8855137966af603109917 |
|
BLAKE2b-256 | 9434185e8b283bd4a5f020d6b651216cf6d3ca8dfcf3e16c4df3d5ee87b0a6d0 |
Close
Hashes for django_multitype_file_field-0.0.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8510df9f7bf013e0b2ec1d461be39170a4d8c86f82233142d959d241728b4fb8 |
|
MD5 | 6719e66771b331e75884559e3eabca27 |
|
BLAKE2b-256 | 571dedb2533616fe47295932e6706ef3a6d0ea922ccc882f6c896b517c3fa743 |