[Answered ]-Django ORM query for empty FileFields

3👍

You can query for empty strings:

# instances with empty FileField
ApplicationInstitution.objects.filter(transcript_file='')
# and with a file already uploaded
ApplicationInstitution.objects.exclude(transcript_file='')

-1👍

transcript_file = FileField(upload_to=..., null=True)

and try this for ApplicationInstitution without file:

ApplicationInstitution.objects.filter(transcript_file__isnull=True)

for ApplicationInstitution with file:

ApplicationInstitution.objects.exclude(transcript_file__isnull=True)
👤arcegk

Leave a comment