Skip to content

ModelSerializer dies on IntegerField with a max_length argument #2317

@hakanw

Description

@hakanw

If an IntegerField, or PositiveIntegerField or any other number field has a max_length argument, then any serialization fails.

Here's the stacktrace:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/hakan/.virtualenvs/opinion/lib/python2.7/site-packages/rest_framework/serializers.py", line 434, in __repr__
    return unicode_to_repr(representation.serializer_repr(self, indent=1))
  File "/Users/hakan/.virtualenvs/opinion/lib/python2.7/site-packages/rest_framework/utils/representation.py", line 75, in serializer_repr
    fields = serializer.fields
  File "/Users/hakan/.virtualenvs/opinion/lib/python2.7/site-packages/rest_framework/serializers.py", line 312, in fields
    for key, value in self.get_fields().items():
  File "/Users/hakan/.virtualenvs/opinion/lib/python2.7/site-packages/rest_framework/serializers.py", line 1044, in get_fields
    ret[field_name] = field_cls(**kwargs)
  File "/Users/hakan/.virtualenvs/opinion/lib/python2.7/site-packages/rest_framework/fields.py", line 647, in __init__
    super(IntegerField, self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'max_length'

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