TypeError: __init__() got an unexpected keyword argument 'many'


While trying to return a query-set using generic views, I get an error

TypeError: init() got an unexpected keyword argument ‘many’

I am unable to understand the source of this error as it seems to be originating from internal libraries. I have no clue as to why this error originated as the create API works just fine.

Complete StackTrace

System check identified 1 issue (0 silenced).
July 16, 2018 - 13:25:43
Django version 1.11.7, using settings 'BirthdayPostStash.settings'
Starting development server at
Quit the server with CONTROL-C.
<QuerySet [<Photos: 1>, <Photos: 2>, <Photos: 3>, <Photos: 4>, <Photos: 5>, <Photos: 6>, <Photos: 7>, <Photos: 8>, <Photos: 9>, <Photos: 10>, <Photos: 11>, <Photos: 12>]>
Internal Server Error: /photos/list-photo/
Traceback (most recent call last):
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/rest_framework/views.py", line 489, in dispatch
    response = self.handle_exception(exc)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/rest_framework/views.py", line 449, in handle_exception
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/rest_framework/views.py", line 486, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/rest_framework/generics.py", line 201, in get
    return self.list(request, *args, **kwargs)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/rest_framework/mixins.py", line 44, in list
    serializer = self.get_serializer(page, many=True)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/rest_framework/generics.py", line 112, in get_serializer
    return serializer_class(*args, **kwargs)
  File "/home/t2b/env/bpstash/local/lib/python2.7/site-packages/rest_framework/fields.py", line 1774, in __init__
    super(ModelField, self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'many'
[16/Jul/2018 13:25:45] "GET /photos/list-photo/ HTTP/1.1" 500 111194


class Photos(models.Model):

owner = models.ForeignKey(User, related_name="photos_owner")
photo = models.ImageField(upload_to=get_image_path, blank=True)
participants = models.ManyToManyField(


class ListPhoto(generics.ListAPIView):
permission_classes = (permissions.IsAuthenticated,)
serializer_class = PhotoPublicSerializer
model = Photos

def get_queryset(self):
    return self.model.objects.all()


class PhotoPublicSerializer(serializers.ModelField):
participants = PersonPublicSerializer(read_only=True)

class Meta:
    model = Photos
    fields = '__all__'


class PersonPublicSerializer(serializers.ModelSerializer):
    class Meta:
        model = Person
        fields = '__all__'


Looks like it was a typo after all.

class PhotoPublicSerializer(serializers.ModelField):
class PhotoPublicSerializer(serializers.ModelSerializer):

Weird things brain does when it’s tired. xD

Answered By – rahul1205

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published