#19195: Using distinct([*fields]) filter on a foreign key produces an ordering error when the foreign key has a Meta ordering field. ----------------------------------------------+---------------------------- Reporter: chrisedgemon@… | Owner: nobody Type: Bug | Status: new Component: Database layer (models, ORM) | Version: 1.4 Severity: Normal | Keywords: distinct, Triage Stage: Unreviewed | query Easy pickings: 0 | Has patch: 0 | UI/UX: 0 ----------------------------------------------+---------------------------- I tried to using a distinct filter like this: Appearance.objects.order_by('team').distinct('team'); this fails with the following Database Error: "DatabaseError: SELECT DISTINCT ON expressions must match initial ORDER BY expressions"
It is possible to work around this problem by using this modified filter: Appearance.objects.order_by('team__id').distinct('team__id'). Model definition: http://pastebin.com/index/J45fy9fr Full traceback: http://pastebin.com/feSFMbzX -- Ticket URL: <https://code.djangoproject.com/ticket/19195> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.