Simple project to validate FileFields/ImageFields, like max size of uploaded files.
Project description
django-file-validator
Simple project to validate FileFields/ImageFields, like max size of uploaded file.
Until now, there is only one validator: MaxSizeValidator.
Dependencies
Django 1.8 or higher (not tested on previous versions)
Installation
pip install django-file-validator
Usage
In your models, import and use MaxSizeValidator:
from django_file_validator.validators import MaxSizeValidator
class YourModle(models.Model):
. . .
image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/img/', validators=[MaxSizeValidator()])
. . .
You can change the max size value passing a parameter on each attibute:
from django_file_validator.validators import MaxSizeValidator
class YourModle(models.Model):
. . .
default_image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/img/', validators=[MaxSizeValidator()])
big_image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/img/', validators=[MaxSizeValidator(2048)])
small_image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/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
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
Close
Hashes for django-file-validator-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d759c83ef177602862fb8c6c2e8f4b1a1ad19a0118a2f4d67f1aa795880de5d4 |
|
MD5 | 259ee23514e0b65f01f5eee3bd90116a |
|
BLAKE2b-256 | fee04e749aec278195be4e6778ce81190b47c281c54477c392c36d7e53f9d37c |