I am running a website through Python
and Django
.
Django-filters=2.1 installed
Django=2.1 installed
When I run, I'm getting the below error.
importError: Could not import 'django_filters.rest_framework.DjangoFilterBackend' for API setting 'DEFAULT_FILTER_BACKENDS'.
ImportError: cannot import name 'QUERY_TERMS' from
'django.db.models.sql.constants' (C:\Users\Android V\AppData\Loc
al\Programs\Python\Python37-32\lib\site-packages\django\db\models\sql\constants.
py).
Short answer: upgrade your django-filter package (not to be confused with the django package) to the latest version.
The reason this fails is because in Django there has been a changeset [GitHub] that indeed removed the QUERY_TERMS
constant from the django.db.models.sql.constants
, to allow the ModelAdmin
to use any lookup. This changes has been deployed in django-2.1 (so in django-2.0, there was still a QUERY_TERMS
constant).
The django-filter-1.1.0 package still used that constant. This is fixed in a changeset [GitHub], and as of django-filter-2.0.0, this is no longer used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With