Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: search (filter) by FileField.name

Tags:

django

I need to find model instances whose FileFields point to a particular set of files. This is probably obvious and documented somewhere but I can't seem to find it: what's the syntax for using FieldField.name in a django filter query? Something like:

models.MyModel.objects.filter(image__name='myfile.jpg')
like image 854
Parand Avatar asked Nov 12 '09 20:11

Parand


1 Answers

Nevermind - it's just

models.MyModel.objects.filter(image='myfile.jpg')

a separate issue was causing me to think this wasn't working, but in fact it is.

like image 159
Parand Avatar answered Sep 28 '22 10:09

Parand