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: max_size_validator.
Dependencies
Django 1.8 or higher (not tested on previous versions)
Installation
pip install django-file-validator
Usage
In your models, import and use max_size_validator:
from django_file_validator.validators import max_size_validator
class YourModle(models.Model):
. . .
image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/img/', validators=[max_size_validator()])
. . .
You can change the max size value passing a parameter on each attibute:
from django_file_validator.validators import max_size_validator
class YourModle(models.Model):
. . .
default_image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/img/', validators=[max_size_validator()])
big_image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/img/', validators=[max_size_validator(2048)])
small_image = models.ImageField( null=True, blank=True, upload_to='uploads/mymodel/img/', validators=[max_size_validator(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.
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.1b.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1acece774e6cb8b9412dcc616db018c2314d02bb610f951d9112fb8371daa34d |
|
MD5 | 959f2c1e3e29761cad056afce9bd595b |
|
BLAKE2b-256 | ce042630cb9726db15e4a4de1556c99731542d56faa9474f952eba7a77617382 |