[Django]-AttributeError at /api/project/ 'Query' object has no attribute 'query_terms' tastypie

2👍

Seems like the current versions of Django and Tastypie don’t go well together.
The fix is hidden in the link given by Nelly Ngo, more specifically here.

A temporary hackish fix is to patch tastypie/resources.py.
At /usr/local/lib/python3.5/dist-packages/tastypie on my system.

Replace the lines:

if getattr(self._meta, 'queryset', None) is not None:
    # Get the possible query terms from the current QuerySet.
    query_terms = self._meta.queryset.query.query_terms
else:
    query_terms = QUERY_TERMS

with:

query_terms = QUERY_TERMS

and

query_terms = query_terms | set(GeometryField.class_lookups.keys())

with:

query_terms |= set(GeometryField.class_lookups.keys())
👤Pepijn

Leave a comment