#35751: Ordering a model via a m2m field creates unintended side effect for
ForeignKeys
-------------------------------------+-------------------------------------
     Reporter:  Dennis Scheiba       |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  ORM ordering         |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * resolution:   => invalid
 * status:  new => closed

Comment:

 
[https://docs.djangoproject.com/en/5.1/ref/models/querysets/#django.db.models.query.QuerySet.order_by
 This behaviour is described in the documentation] under the note that
 covers ''It is permissible to specify a multi-valued field to order the
 results by''.

 > Using a many to many relation for ordering (which is something you
 shouldn't do?)

 Could you describe wha are you expecting to happen when specifying
 `order_by(booking_times__date)` if not for each item to be returned
 multiple times? Are you looking for `order_by(Min("booking_times__date"))`
 instead?
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35751#comment:4>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070191ddc5bc7c-d787da11-e09d-4a79-8e9f-76b3d8a274ec-000000%40eu-central-1.amazonses.com.

Reply via email to