-->

Django - check for null in database

By: Varghese Chacko 1 year, 5 months ago

isnull

In django, the NULL valuein the database field is tested with field lookup isnull It takes either True or False, which correspond to SQL queries of IS NULL and IS NOT NULL, respectively.

Example:

Entry.objects.filter(pub_date__isnull=True)

SQL equivalent:

SELECT * from enty WHERE pub_date IS NULL;

Wish to hire us?

We take the vision which comes from dreams and apply the magic of science and mathematics, adding the heritage of our profession and our knowledge to create a design.