Skip to content

allow_empty does not work on serializers with many=True. #3361

@pmdarrow

Description

@pmdarrow

Is this expected behaviour?

>>> from rest_framework import serializers
>>>
>>> class ChildSerializer(serializers.Serializer):
...     name = serializers.CharField()
...
>>> class ParentSerializer(serializers.Serializer):
...     children = ChildSerializer(many=True, allow_empty=False)
...
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "<console>", line 2, in ParentSerializer
  File "/Users/pmdarrow/.virtualenvs/api/lib/python3.4/site-packages/rest_framework/serializers.py", line 96, in __new__
    return cls.many_init(*args, **kwargs)
  File "/Users/pmdarrow/.virtualenvs/api/lib/python3.4/site-packages/rest_framework/serializers.py", line 116, in many_init
    child_serializer = cls(*args, **kwargs)
  File "/Users/pmdarrow/.virtualenvs/api/lib/python3.4/site-packages/rest_framework/serializers.py", line 90, in __init__
    super(BaseSerializer, self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'allow_empty'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy