Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7608 closed (worksforme)

ImageField Validation Fails with Deprecation Warning

Reported by: Mogga <rob@…> Owned by: nobody
Component: Validators Version: dev
Severity: Keywords: ImageField, upload
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I get the following apache error on trunk revision 7825 when adding images to a model entry.

site-packages/django/core/ DeprecationWarning: The dictionary access of uploaded file objects is deprecated. Use the new object interface instead.
  content = field_data['content']

The admin interface displays the following error message:

Upload a valid image. The file you uploaded was either not an image or a corrupted image.

I have libjpeg, PIL, etc. installed. This was working code before the update. Fails on CentOS 4.6 and Mac OS X 10.5.4

CentOS setup...

  • Django revision is 7825.
  • python 2.3.4-14.4.el4_6.1
  • httpd 2.0.52-38.ent.centos4
  • MySQL-python.i386 1.2.1_p2-1.el4.1
  • mod_python.i386 3.1.3-5.1

Change History (3)

comment:1 by Malcolm Tredinnick, 16 years ago

Resolution: worksforme
Status: newclosed

DeprecationWarning isn't an error. It's a warning. It doesn't cause anything to fail. Note that the error you're seeing reported is not the one that is raised immediately following the warning line. Instead, you're seeing the error message that is raise when PILL cannot understand the content that is passed in.

I created an app with an ImageField and was able to upload both valid JPEG and PNG images without any problems. I saw the deprecation warning, but, as I said, it's harmless. So I suspect the problem here is that the image you're trying to upload really is invalid. If you can reliably repeat the problem, please verify the lines in the image validator at a Python shell with that image to see which one is causing the problem (that is, import PIL at a Python prompt, load the image data, verify it, etc, just like the Django code does).

Closing for now, though, since I don't think this is the bug that is being reported (and I'll remove the deprecation warning now).

comment:2 by Malcolm Tredinnick, 16 years ago

(In [7837]) Changed a couple of old-style validators to remove some deprecation warnings
when using ImageFields, etc, in the admin interface. Cosmetic only. Refs #7608.

comment:3 by Jacob, 13 years ago

milestone: 1.0 alpha

Milestone 1.0 alpha deleted

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