django rest framework ошибка " TypeError: объект 'type' не повторяется"

Я не знаю, какую конфигурацию изменить.

URL моего git-репозитория: https://github.com/Nomadcoders-Study/Nomadgram

Internal Server Error: /images/all/
Traceback (most recent call last):
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/rest_framework/views.py", line 478, in dispatch
request = self.initialize_request(request, *args, **kwargs)
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/rest_framework/views.py", line 380, in initialize_request
authenticators=self.get_authenticators(),
  File "/usr/local/var/pyenv/versions/3.6.1/envs/nomadgram/lib/python3.6/site-packages/rest_framework/views.py", line 274, in get_authenticators
  return [auth() for auth in self.authentication_classes]
TypeError: 'type' object is not iterable

1 ответ

Решение

В файле settings.py добавьте запятую в конце '...JSONWebTokenAuthentication' строка, как показано ниже:

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
    ),
}

внимание: без запятой это не кортеж

Другие вопросы по тегам