Django: Elegant way to lookup a non-empty string
I have a model Chair with a blank-able CharField called wood_type.
I want to filter all the chairs with a wood_type which is not ''.
What's an elegant way to do it with Django?
I can think of this:
Chair.filter(~django.db.models.Q(wood_type=''))
Or this:
Chair.filter(wood_type__regex='(.|\n)+')
But they're ugly as hell. Is there a more elegant way?
No comments:
Post a Comment