D
D
Dauren S2016-07-26 08:14:03
Django
Dauren S, 2016-07-26 08:14:03

Django how to select NULL?

There is a table of categories, it has a parent_id field, how to make a selection of values ​​\u200b\u200bfor which the parent_id = NULL field. Now it gives an error

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2016-07-26
@dauren101

You can use the filter operator isnull
Category.objects.filter(parent_id__isnull=True)

P
Pan Propan, 2016-07-26
@mgis

Use None in the filter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question