Django-filter: Problem with DRF pagination

Created on 18 Jul 2018  ·  3Comments  ·  Source: carltongibson/django-filter

If I use these settings with DRF pagination, I have some errors

REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS': (
        'django_filters.rest_framework.DjangoFilterBackend'
    ),
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 100   
}
rics.py", line 151, in filter_queryset
    for backend in list(self.filter_backends):
TypeError: 'RenameAttributes' object is not iterable

If I remove DEFAULT_FILTER_BACKENDS, it will work. Is that right?

Most helpful comment

Hi @csarcom. The issue is that your DEFAULT_FILTER_BACKENDS is actually a string, not a tuple. You've wrapped the backend string in parentheses but left off the comma, so the parens evaluate the contents instead of creating a tuple. I typically recommend that users use lists instead of tuples for this reason.

All 3 comments

Hi @csarcom. The issue is that your DEFAULT_FILTER_BACKENDS is actually a string, not a tuple. You've wrapped the backend string in parentheses but left off the comma, so the parens evaluate the contents instead of creating a tuple. I typically recommend that users use lists instead of tuples for this reason.

Great Thank you

Thanks

Was this page helpful?
0 / 5 - 0 ratings