I need analog of sql IS_NULL function. In postgres, for example, I can write like this
coalesce(field, 'Empty')
How I can implement this using Django?
I need analog of sql IS_NULL function. In postgres, for example, I can write like this
coalesce(field, 'Empty')
How I can implement this using Django?
You can use extra queryset method:
MyModel.objects.extra(select={'field': "coalesce(field, 'Empty')"})
COALESCE should work similarly in most db engines.