This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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.

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
    
Release History

Release History

This version
History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

History Node

0.0.1b2

History Node

0.0.1b

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-file-validator-0.0.7.tar.gz (5.1 kB) Copy SHA256 Checksum SHA256 Source Sep 25, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting