jazzband / django-polymorphic

Improved Django model inheritance with automatic downcasting

Home Page:https://django-polymorphic.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Polymorphic order_by

jahnagoldman opened this issue · 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!