Your suggestion will give you an error. Try instead:
UserImage.objects.filter(photo='a.jpg')
Edit: Django adds the upload_path to the file name. Then the request should do something like this, for example:
UserImage.objects.filter(photo='images/users/photos/a.jpg')
source
share