Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rest_framework.filters.OrderingFilters to TemplateViewSet filter_… #352

Merged
merged 1 commit into from
Sep 27, 2022

Conversation

richardhadden
Copy link

#339 Sorting not implemented; added the rest_framework OrderingFilters, which allows filtering on fields using ordering param

…backends

#339 Sorting not implemented; added the rest_framework OrderingFilters, which allows filtering on fields using `ordering` param
@SteffRhes SteffRhes self-assigned this Sep 27, 2022
@SteffRhes
Copy link
Member

Tested. Works.

Just FYI: I also quickly tested the unlikely edge-case where an entity has an attribute ordering since the REST params can not distinguish between entity attributes and "meta parameters" such as ordering defining the order of results.

If an entity now has an attribute ordering, then drf will use that instead of interpreting it as the order of results.

E.g. I gave a place an ordering field and in one place instance I gave this field the value "name". Now when using ?ordering=name then it will only return that one place and not any others.

@SteffRhes SteffRhes closed this Sep 27, 2022
@SteffRhes SteffRhes reopened this Sep 27, 2022
@SteffRhes SteffRhes merged commit c79e70e into main Sep 27, 2022
@richardhadden
Copy link
Author

Nice edge-case testing! I guess this is the case whatever you call the meta-parameter for sorting — always a chance someone will use that as a field name (maybe ordering is chosen by DRF as default as it's less likely to be a field name: sort can be a synonym for type/genre etc.)

@SteffRhes SteffRhes deleted the rh/fixes/sort-list-view-not-working branch September 27, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants