django-file-validator
Simple project to validate FileFields/ImageFields, like max size of uploaded file.
Until now, there is only one validator: MaxSizeValidator.
NOT WORKING WITH NEW DJANGO 1.10.
Dependencies
Django 1.8 or higher (not tested on previous versions) but lower than 1.10!!
Installation
pip install django-file-validator
Usage
In your models, import and use MaxSizeValidator:
from django_file_validator.validators import MaxSizeValidator
class YourModel(models.Model):
. . .
image = models.ImageField( null=True, blank=True, upload_to='uploads/yourmodel/img/', validators=[MaxSizeValidator()])
. . .
You can change the max size value passing a parameter on each attibute:
from django_file_validator.validators import MaxSizeValidator
class YourModel(models.Model):
. . .
default_image = models.ImageField( null=True, blank=True, upload_to='uploads/yourmodel/img/', validators=[MaxSizeValidator()])
big_image = models.ImageField( null=True, blank=True, upload_to='uploads/yourmodel/img/', validators=[MaxSizeValidator(2048)])
small_image = models.ImageField( null=True, blank=True, upload_to='uploads/yourmodel/img/', validators=[MaxSizeValidator(256)])
. . .
Configurations
- FILE_SIZE_LIMIT_IN_KILOBYTES
You can change the default max size limit of uploaded files, just putting this variable on settings.py. Default value is 512 kB.
FILE_SIZE_LIMIT_IN_KILOBYTES=512
Metadata
Release files for django-file-validator 0.0.7
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 | |
|---|---|---|---|---|
| django-file-validator-0.0.7.tar.gz | 5.1 kB | Without provenance | Details |
Release files / django-file-validator-0.0.7.tar.gz
| Download URL | django-file-validator-0.0.7.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd302804157f267ad121f2c8d77099a158fe4bcdc7633c8059c88b12a4a8ff2f
|
|
BLAKE2b-256 checksum How to use checksums |
5c57541efa1da3ae55640c7fcbeff63272a89fb7ce7f789042d1ffb8a537e2a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-file-validator 0.0.7
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.