MSSQL - DISTINCT ON fields is not supported by this database backend

Viewed 63

I have this form

class FromToForm(Form):
   ModelChoiceField(queryset=TblWorkPlace.objects.all().distinct('work_place_name'))

Django writes this error message:

DISTINCT ON fields is not supported by this database backend

Is there some workaround?

1 Answers

distinct('field_name') is not supported in MySQL. It only support distinct()

MySQL is fine when you want to test out, but most (if not all) database in production do not use Mysql but Postgres.

The good thing with using Postgres is that you unlock a lot of special feature that Django have specifcly for Postgres.

Related