I'm using distinct()
QuerySet to get some data in Django.
My initial query was Point.objects.order_by('chron', 'pubdate')
.
The field chron
in some cases is a duplicate so I changed the query
to Point.objects.order_by('chron', 'pubdate').distinct('chron')
in order to exclude duplicates.
Now the problem is that all empty fields are considered duplicates.
To be accurate, the chron
field contain integers (which behave similar to ids), in some cases it can be a duplicate, in some cases it can be NULL.
| chron |
|-------|
| 1 | I want this
| 2 | I want this
| 3 | I want this
| 3 |
| NULL |
| 4 | I want this
| NULL |
I want to exclude all the chron
duplicates but not if they are duplicate of NULL.
Thank you.