django-ninja-extra icon indicating copy to clipboard operation
django-ninja-extra copied to clipboard

Can ordering feature cross relations?

Open ddahan opened this issue 1 year ago • 4 comments

Hi there!

I used searching feature and was pleased to notice that search fields can cross relationships, for example with:

@searching(Searching, search_fields=["owner__first_name", "owner__last_name"])

However, I'm wondering how to have a similar behaviour with ordering feature. As of now, it seems that it is considered to be a wrong field. For example, something like this will have no effect on ordering:

image

How can I do? Thanks a lot.

ddahan avatar Dec 13 '23 10:12 ddahan

@ddahan you mean you want searching query for and ordering action?

eadwinCode avatar Dec 14 '23 19:12 eadwinCode

Nope, I just want to be able to "order_by" across relation.

For example, this would work in a shell:

Badge.objects.order_by("owner__first_name")

But would not work (no effect on ordering) with my api call to :

http://localost:8000/api/badges?page=1&ordering=owner__first_name

ddahan avatar Dec 15 '23 08:12 ddahan

Oh okay I see what you mean. I will take a look and revert

eadwinCode avatar Dec 15 '23 10:12 eadwinCode