Skip to content

Polymorphic order_by #518

@jahnagoldman

Description

@jahnagoldman

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions