Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7673 closed (fixed)

ImageField validation problem

Reported by: Luca Lenardi Owned by: Jacob
Component: Forms Version: master
Severity: Keywords: 2070-fix
Cc: boobsd@…, justin.driscoll@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

form.cleaned_data[image_field].read() seems to be empty when validating with custom validation using newforms.

...
if hasattr(data, 'temporary_file_path'):
    file = data.temporary_file_path()
else:
    if hasattr(data, 'read'):
        file = StringIO(data.read())
    else:
        file = StringIO(data['content'])
...

data.read() in the clean() method of ImageField becomes empty after the first read making the file unreadable in next custom validation.

Attachments (1)

newforms_imagefix.diff (522 bytes) - added by Michael Axiak 8 years ago.
Fix for this...thanks apollo13!

Download all attachments as: .zip

Change History (9)

comment:1 Changed 8 years ago by Luca Lenardi

With custom validation, I mean implementing the clean_fieldname() method in a form using newforms.

comment:2 Changed 8 years ago by anonymous

Owner: changed from nobody to anonymous
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:3 Changed 8 years ago by Boo

Cc: boobsd@… added

comment:4 Changed 8 years ago by Michael Axiak

Has patch: set
Keywords: 2070-fix added
Owner: changed from anonymous to Michael Axiak
Status: assignednew
Triage Stage: AcceptedReady for checkin

Uploading a patch to fix this.

Changed 8 years ago by Michael Axiak

Attachment: newforms_imagefix.diff added

Fix for this...thanks apollo13!

comment:5 Changed 8 years ago by Jacob

Owner: changed from Michael Axiak to Jacob
Status: newassigned

comment:6 Changed 8 years ago by anonymous

Cc: justin.driscoll@… added

comment:7 Changed 8 years ago by Jacob

Resolution: fixed
Status: assignedclosed

(In [7907]) Fixed #7673: make sure to rewind uploaded image data when validating ImageFields. Thanks, Mike Axiak.

comment:8 Changed 5 years ago by Jacob

milestone: 1.0 beta

Milestone 1.0 beta deleted

Note: See TracTickets for help on using tickets.
Back to Top