Opened 16 years ago

Closed 16 years ago

#10749 closed (duplicate)

ImageField is a string in the lookup api

Reported by: r.pelizzi@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords: ImageField
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I was trying to retrieve objects which didn't have the image attribute (an ImageField) set yet, so i tried with MyModel.objects.filter(image=None). It didn't match any entry... image__isnull didn't work as well. Then i found out that I had to do MyModel.objects.filter(image=""). So basically it seems that the ImageField is exposed as a string, as far as the lookup api is concerned. (I'm not familiar with django enough to look into django's source code to confirm this). It doesn't seem like a consistent behaviour to me, since the imagefields are high-level objects when accessed from instances.

Change History (1)

comment:1 by Karen Tracey, 16 years ago

Resolution: duplicate
Status: newclosed

This is really the same as #10244. Searching for None doesn't work because there is no way for NULL to be stored as the "empty" value for a FileField, the empty string is always used as the value.

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