Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#7673 closed (fixed)

ImageField validation problem

Reported by: Luca Lenardi Owned by: Jacob
Component: Forms Version: dev
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: no UI/UX: no

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 16 years ago.
Fix for this...thanks apollo13!

Download all attachments as: .zip

Change History (9)

comment:1 by Luca Lenardi, 16 years ago

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

comment:2 by anonymous, 16 years ago

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

comment:3 by Boo, 16 years ago

Cc: boobsd@… added

comment:4 by Michael Axiak, 16 years ago

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.

by Michael Axiak, 16 years ago

Attachment: newforms_imagefix.diff added

Fix for this...thanks apollo13!

comment:5 by Jacob, 16 years ago

Owner: changed from Michael Axiak to Jacob
Status: newassigned

comment:6 by anonymous, 16 years ago

Cc: justin.driscoll@… added

comment:7 by Jacob, 16 years ago

Resolution: fixed
Status: assignedclosed

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

comment:8 by Jacob, 12 years ago

milestone: 1.0 beta

Milestone 1.0 beta deleted

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