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

Not compatible with QuerySetNoCache() #76

Open
mgoffin opened this issue Apr 10, 2014 · 1 comment
Open

Not compatible with QuerySetNoCache() #76

mgoffin opened this issue Apr 10, 2014 · 1 comment

Comments

@mgoffin
Copy link

mgoffin commented Apr 10, 2014

If you are inheriting from MongoEngine's QuerySetNoCache() instead of QuerySet() for a custom QuerySet, the you will get the following error:

File \"/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tastypie/resources.py\", line 1930, in build_filters

    query_terms = self._meta.queryset.query.query_terms

AttributeError: 'CustomQuerySet' object has no attribute 'query'

If you lift the code from lines 32-41 of resources.py and add it to your custom QuerySet class, things will work. Seems like that code is very specific to using the cached QuerySet and not supporting the non-cached version?

@mitar
Copy link
Member

mitar commented Nov 30, 2014

This is code from Tastypie. We extend the code which assumes that it uses Django ORM, and then we override things for MongoEngine.

It would be helpful if you provide whole stack. Because then we could see where from this code is called and if it goes somewhere through our code. Maybe in some other case we already have a workaround, which checks for example for class instance and is not patching here the queryset.

The best would be if you could make a pull request with the test which is failing for you.

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

No branches or pull requests

2 participants