Code

Opened 6 years ago

Closed 6 years ago

#7632 closed (duplicate)

UploadedFile does not work correctly with forms.ImageField (newforms)

Reported by: tek Owned by: axiak
Component: Uncategorized Version: master
Severity: Keywords: UploadedFile, forms.ImageField,2070-fix
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by mtredinnick)

I tried all the same with "forms.Field" - works well. But there is a problem if I try to use "forms.ImageField", it can't work correctly with the UploadedFile
This can be seen if you try to process the downloaded pictures using lib PIL.Image .

forms.py
It's not work:

class UploadFileForm(forms.Form):
    img = forms.ImageField(widget=forms.FileInput())  # or simple forms.ImageField()

It's work fine:

class UploadFileForm(forms.Form):
    img = forms.Field(widget=forms.FileInput())

I think it's bug, new version UploadedFile do not work as well as older.

For example what I am doing:

               UploadedFile    =>   data = StringIO(UploadedFile.read())   =>  Image.open(data) 

And what I got:

              IOError at /upload_image/
              '''cannot identify image file'''

It's work only if I use "forms.Field"

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by mtredinnick

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Fixed ticket description formatting.

comment:2 Changed 6 years ago by axiak

  • Keywords forms.ImageField,2070-fix added; forms.ImageField removed
  • Owner changed from nobody to axiak
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

I'd like to close this as a duplicate of #7673, but I have no idea what you are trying to say. Does the patch in #7673 fix what your problem is?

comment:3 Changed 6 years ago by axiak

  • Resolution set to duplicate
  • Status changed from assigned to closed

I'm closing this as a duplicate of #7673 and #7675. Please feel free to reopen if you do not think that those tickets do not fix this issue.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.