Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Added __ traversal support #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

wojas
Copy link

@wojas wojas commented Nov 14, 2012

In order to make this work, I had to do the datetime check differently. Also made timestamps a float to support higher resolutions.

@pennersr
Copy link
Owner

Thanks! I am wondering though, can't we get rid of the "pagemore_ts" parameter you introduced? It should be possible to derive whether or not the field you sort on is a timestamp from the _meta of the model/field itself instead of passing this to/from the client.

@wojas
Copy link
Author

wojas commented Nov 15, 2012

It's not possible, because the field will not be on the model you have a queryset for if the __ trick is used. Additionally, at the moment you use it, no query has been done yet, so you cannot just use the first result from the query.

It would be possible to do this fields that do not use the __ trick and only add the parameter for deeper fields.

@pennersr
Copy link
Owner

This is possible. Here's an example using the standard Django auth models, where you can filter on accessor fields like this:

>>> User.objects.filter(groups__name='x')

In order to get your hands on the type of the name attribute (without performing any queries), do this:

>>> u.groups.model._meta.get_field('name')
<django.db.models.fields.CharField: name>

So basically you can check what the type of the field (obj._meta.get_field(field)) and depending on whether or not it is a related field, fk etc. look the type up as above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants