custom file validation
Hi,
I have a file in a form. The file is optional but if the file is not
None, then some other form fields are required as well. For example
the following code checks one of the fields that's required when the
file fields isn't empty:
file = forms.FileField(required=False)
def clean_canvas_height(self):
canvas_height = self.cleaned_data['canvas_height']
file = self.cleaned_data['file']
if file is not None and canvas_height is None:
raise forms.ValidationError('You must specify a canvas
height')
return canvas_height
this produces a KeyError which I'm gathering I can't access the file
info this way. My question is how can I go about writting a custom
validation against a file field.
Cheers!
D
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home