Code

Opened 5 years ago

Closed 5 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: UI/UX:

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.

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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.

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.