rsinger86/drf-flex-fields

AttributeError 'map' object has no attribute 'split'

Closed this issue · 0 comments

Hello,

I started getting this error after upgrading to Python 3 where fields is a generator and not a list.

Traceback:  

File "/app/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/app/.venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/app/.venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/app/.venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/app/.venv/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  58.         return view_func(*args, **kwargs)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/viewsets.py" in view
  103.             return self.dispatch(request, *args, **kwargs)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
  483.             response = self.handle_exception(exc)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
  443.             self.raise_uncaught_exception(exc)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
  480.             response = handler(request, *args, **kwargs)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/mixins.py" in list
  44.             serializer = self.get_serializer(page, many=True)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/generics.py" in get_serializer
  112.         return serializer_class(*args, **kwargs)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/serializers.py" in __new__
  124.             return cls.many_init(*args, **kwargs)

File "/app/.venv/lib/python3.7/site-packages/rest_framework/serializers.py" in many_init
  145.         child_serializer = cls(*args, **kwargs)

File "/app/.venv/lib/python3.7/site-packages/rest_flex_fields/serializers.py" in __init__
  34.         sparse_fields, next_sparse_fields = split_levels(fields)

File "/app/.venv/lib/python3.7/site-packages/rest_flex_fields/utils.py" in split_levels
  27.         fields = [a.strip() for a in fields.split(",") if a.strip()]

AttributeError at /api/v2/users/
'map' object has no attribute 'split'

Running on Python 3.7

Django==1.11.25
djangorestframework==3.8.2
drf-flex-fields==0.6.1

I can submit a PR to fix this issue if you don't mind