6
7
class UploadImageForm(forms.Form):
7
8
# max_length = 90 because the length of 'upload_to =' has to be considered
8
9
imagename = forms.ImageField(max_length=90)
11
12
# clean_<name_of_fieldvar>() acts only for this specific field
14
15
if Image.objects.has_image(in_mem_img.name):
15
16
# Get the existing image to show its properties
17
18
raise forms.ValidationError(
18
19
("There is already an image with name '%(name)s' attached to %(object)s '%(obj_name)s'. \
19
20
Use the existing image or rename your file and upload gain."),
20
params={'name': exist_img.name, 'object': exist_img.content_type, 'obj_name': exist_img.content_object}