Changes between Version 3 and Version 4 of CookBookValidateImageWeight


Ignore:
Timestamp:
07/25/2006 10:24:31 AM (9 years ago)
Author:
Ville@…
Comment:

Updated to MR

Legend:

Unmodified
Added
Removed
Modified
  • CookBookValidateImageWeight

    v3 v4  
    11= CookBook - Validate an image weight =
    2 django version : 0.91
     2
     3django version : POST-MR
    34
    45To check the weight an image uploaded via your form, you
     
    1011#!python
    1112def isValideSize(field_data, all_data):
     13        if len(all_data["image_file"]["content"]) > 100000: # 100,000 bytes
     14                raise validators.ValidationError, "File is too large"
     15}}}
     16
     17----
     18
     19== Older versions of Django ==
     20
     21django version : 0.91
     22
     23== Code ==
     24Here we check that the image under 100 kb.
     25{{{
     26#!python
     27def isValideSize(field_data, all_data):
    1228        if len(field_data["content"]) > 100000: # 100,000 bytes
    1329                raise validators.ValidationError, "File is too large"
Back to Top