[Django error]'RenameAttributes' object is not iterable

Introduction

Django's error memorandum. When django-rest-framework was introduced. TypeError 'RenameAttributes' object is not iterable

Conclusion

It was caused by settings.py. this

settings.py


# TypeError 'RenameAttributes' object is not iterable
REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS': 'django_filters.rest_framework.DjangoFilterBackend', 
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 5
}

do this

settings.py


REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',), 
    'DEFAULT_PAGINATION_CLASS': ('rest_framework.pagination.PageNumberPagination'),
    'PAGE_SIZE': 5
}

I was able to do this

settings.py


REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',), 
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 5
}

Other errors

settings.py


# TypeError 'RenameAttributes' object is not iterable
REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend'), 
    'DEFAULT_PAGINATION_CLASS': ('rest_framework.pagination.PageNumberPagination'),
    'PAGE_SIZE': 5
}

settings.py


# TypeError 'list' object is not callable
REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS':['django_filters.rest_framework.DjangoFilterBackend'], 
    'DEFAULT_PAGINATION_CLASS': ['rest_framework.pagination.PageNumberPagination'],
    'PAGE_SIZE': 5
}

in conclusion

I don't know why it didn't work, so inconvenience may occur later ... Did you get an error after trying a lot? It was a memorandum.

Recommended Posts

[Django error]'RenameAttributes' object is not iterable
TypeError:'int' object is not subscriptable
I got a TypeError:'int' object is not iterable when using keras
[Hyperas] Type Error: Resolving'function' object is not subscriptable
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
When the selected object in bpy.context.selected_objects is not returned
About "RuntimeWarning: Pickled model instance's Django version is not specified"
Python round is not strictly round
Is time.time () not very accurate?
Is Python's Object Orientation Retrofit?
NameError: name'__file__' is not defined