ImportError: Could not import 'rest_framework.filters.DjangoFilterBackend' for API setting

2,717 views
Skip to first unread message

Praveen Kumar

unread,
Jan 18, 2019, 6:15:58 PM1/18/19
to Django REST framework

I am upgrading Django from 1.8 to 2.1.5 and Python 2.7 to 3.6. On the process, I upgraded djangorestframework to 3.8.2 from 3.6.4.



After upgrade, I see this error trace:

File "/usr/local/lib/python3.6/dist-packages/rest_framework/generics.py", line 26, in 

class GenericAPIView(views.APIView):

File "/usr/local/lib/python3.6/dist-packages/rest_framework/generics.py", line 45, in GenericAPIView

filter_backends = api_settings.DEFAULT_FILTER_BACKENDS

File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 227, in getattr

val = perform_import(val, attr)

File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 172, in perform_import

return [import_from_string(item, setting_name) for item in val]

File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 172, in 

return [import_from_string(item, setting_name) for item in val]

File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 187, in import_from_string

raise ImportError(msg)

ImportError: Could not import 'rest_framework.filters.DjangoFilterBackend' for API setting 'DEFAULT_FILTER_BACKENDS'. AttributeError: module 'rest_framework.filters' has no attribute 'DjangoFilterBackend'.


I am not sure where I am going wrong. Any help on this issue is much appreciated.

Jakob Damgaard Møller

unread,
Jan 19, 2019, 1:41:11 AM1/19/19
to django-res...@googlegroups.com
And you have installed the Django filter as described below:



--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Jakob Damgaard Olsen
Tlf: 24613112

Carlton Gibson

unread,
Jan 19, 2019, 5:26:15 AM1/19/19
to django-res...@googlegroups.com
The backend was moved out in 3.5 and went through the deprecation process, finally being removed in 3.7. 


Update your imports to use django_filters.rest_framework, as per the docs linked in Jakob's reply. 

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages