I am using distinct to get the distinct latest values but it is giving me an error:
DISTINCT ON fields is not supported by this database backend
<
distinct('field_name')
is not supported in MySQL. It only support distinct()
. distinct('field_name')
will only work on PostgresSQL. For more details, please check the documentation.
Examples (those after the first will only work on PostgreSQL):(Copy Pasted from Documentation:)
>>> Author.objects.distinct()
[...]
>>> Entry.objects.order_by('pub_date').distinct('pub_date')
[...]
>>> Entry.objects.order_by('blog').distinct('blog')
[...]
>>> Entry.objects.order_by('author', 'pub_date').distinct('author', 'pub_date')
[...]
>>> Entry.objects.order_by('blog__name', 'mod_date').distinct('blog__name', 'mod_date')
[...]
>>> Entry.objects.order_by('author', 'pub_date').distinct('author')
[...]