how to add condition if null value in django orm

MyModel.objects.filter(field__isnull = False)

Here is what the above code is Doing:
1. It’s creating a queryset of all MyModel objects that have a non-null value for field.
2. It’s iterating over that queryset, and for each object it’s retrieving the value of field.
3. It’s printing out the value of field.

The above code is equivalent to the following SQL:

SELECT field
FROM myapp_mymodel
WHERE field IS NOT NULL