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
Ordering by excluded field not possible #607
Comments
The implemented behavior seems the most reasonable to me... If you're excluding a field from being visible from the API, then from the perspective of the person consuming your API, it doesn't exist at all. Do you have a particular scenario in which this behavior should be allowed? |
From a security point of view, the sorting leaks information about the On Fri, Aug 10, 2012 at 6:10 AM, Daniel McDonald
|
I'm using tastypie on a site that gives user content a "popularity score". I want to allow sorting results by popularity without exposing the actual numerical scores. Mainly because they're not useful for anything except sorting and only serve to make the api responses less understandable, but also because I don't want to make it too easy to figure out the popularity scoring in an attempt to game the system. |
As far as I see, even if you explicitly mention in
Resource
'sMeta
some field that should allow ordering (by supplying it as element of the list inMeta.ordering
property), you cannot actually sort by that field, if it is given within theMeta.excludes
list of excluded fields.The code responsible for such behaviour (and visible here) is here:
Is that intended behaviour? I would expect ability to sort by some field (by adding its name to
ordering
option), even if I do not want this field to be displayed in the output (which I currently fulfill by supplying its name intoexcludes
option).The text was updated successfully, but these errors were encountered: