CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/html;charset=utf-8
cache-control: must-revalidate
expires: Fri, 01 Jan 1999 00:00:00 GMT
set-cookie: trac_form_token=c0d0b3302f4131d72d85f431; HttpOnly; Path=/; Secure
set-cookie: trac_session=0b3639f29fe5c1aea725c567; expires=Tue, 21 Oct 2025 05:40:27 GMT; HttpOnly; Path=/; Secure
strict-transport-security: max-age=31536000; includeSubDomains; preload
permissions-policy: interest-cohort=()
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
accept-ranges: bytes
via: 1.1 varnish, 1.1 varnish
date: Wed, 23 Jul 2025 05:40:27 GMT
x-served-by: cache-fra-eddf8230123-FRA, cache-bom-vanm7210045-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753249228.575471,VS0,VE332
vary: Accept-Encoding
CookBookValidateImageWeight – Django
Back to Top
Django
The web framework for perfectionists with deadlines.
Issues
CookBook - Validate an image weight
django version : POST-MR
To check the weight an image uploaded via your form, you can implement this method into your view.py or custom manipulator.
Code
Here we check that the image under 100 kb.
def isValideSize(field_data, all_data): if len(all_data["image_file"]["content"]) > 100000: # 100,000 bytes raise validators.ValidationError, "File is too large"
Older versions of Django
django version : 0.91
Code
Here we check that the image under 100 kb.
def isValideSize(field_data, all_data): if len(field_data["content"]) > 100000: # 100,000 bytes raise validators.ValidationError, "File is too large"
Last modified
19 years ago
Last modified on Jul 25, 2006, 10:24:31 AM
Note:
See TracWiki
for help on using the wiki.
Download in other formats:
Django Links
Learn More
Get Involved
Follow Us
- Hosting by In-kind donors
- Design by Threespot &
© 2005-2025 Django SoftwareFoundation unless otherwise noted. Django is a registered trademark of the Django Software Foundation.