django-polymorphic icon indicating copy to clipboard operation
django-polymorphic copied to clipboard

Polymorphic order_by

Open jahnagoldman opened this issue 3 years ago • 0 comments

In the documentation, it's mentioned you can use Q objects for filtering by different fields i.e.

items.filter(
    Q(ModelA___field1 = 4) |
    Q(ModelB___field2 = 4) |
    Q(ModelC___field3 = 4)
)

and then mentions order_by() similarly supports the ModelX___field syntax for specifying ordering through a field in a submodel.

What's the correct syntax for using order_by with different fields on each model? I personally wasn't able to get anything to work properly. Thanks so much!

jahnagoldman avatar May 05 '22 01:05 jahnagoldman