Ticket #1687: UploadSize.diff
File UploadSize.diff, 1.3 KB (added by , 19 years ago) |
---|
-
magic-removal/django/forms/__init__.py
636 636 #################### 637 637 638 638 class FileUploadField(FormField): 639 def __init__(self, field_name, is_required=False, validator_list=[]): 639 def __init__(self, field_name, is_required=False, validator_list=[], 640 length=None): 640 641 self.field_name, self.is_required = field_name, is_required 641 642 self.validator_list = [self.isNonEmptyFile] + validator_list 643 if length: 644 self.length = "size=\"%s\"" % str(length) 645 else: 646 self.length = "" 642 647 643 648 def isNonEmptyFile(self, field_data, all_data): 644 649 if not field_data['content']: 645 650 raise validators.CriticalValidationError, gettext("The submitted file is empty.") 646 651 647 652 def render(self, data): 648 return '<input type="file" id="%s" class="v%s" name="%s" />' % \ 649 (self.get_id(), self.__class__.__name__, self.field_name) 653 return '<input type="file" id="%s" class="v%s" %s name="%s" />' % \ 654 (self.get_id(), self.__class__.__name__, self.length, 655 self.field_name) 650 656 651 657 def html2python(data): 652 658 if data is None: