Opened 5 years ago

Last modified 13 months ago

#10935 new Cleanup/optimization

forms.ImageField.clean should annotate the object returned by FileField.clean

Reported by: jdunck Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


ImageField.clean does some validation that the given file is, in fact, an image, but then just returns whatever the FileField gave it-- generally an UploadedFile.

I have a later Form.clean_* method which needs to do further work with the image, and so uses again.

I think it'd be good to annotate the UploadedFile with an image attribute to save the work of parsing the image yet again.

f.image = trial_image


Attachments (0)

Change History (8)

comment:1 Changed 5 years ago by jdunck

Also, as long as it's opening the image, I think it should correct content_type based on the actual format of the image. Most OS's will mis-report the content type of the upload based on its extension, so that a JPEG named something.gif is reported as image/gif.

comment:2 Changed 4 years ago by jcd

  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 4 years ago by jacob

  • milestone changed from 1.2 to 1.3

I'm calling this a feature, and kicking it out of 1.2.

comment:4 Changed 3 years ago by ubernostrum

  • milestone 1.3 deleted

1.3 is feature-frozen now.

comment:5 Changed 3 years ago by lukeplant

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:6 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:7 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:8 Changed 13 months ago by jacob

  • Triage Stage changed from Design decision needed to Accepted

Add Comment

Modify Ticket

Change Properties
<Author field>
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'

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

Note: See TracTickets for help on using tickets.