Skip to content

Problem when using camelcase fieldnames in fields filter on CollectionSerializer #3

@MRigal

Description

@MRigal

Dear @onyg ,

First of all, thanks for the fantastic work you made by writing this serializer. It is really cool and would deserve to be much more known !

Unfortunately, I found a bug in the DjangoCollectionSerializer.

When you try to use it in combination with the fields argument and that you pass some camelCase fieldnames in the fields list, these won't appear in DjangoCollectionSerializer output.

Tracking down a bit the error, passing the underscored fields we could find that self._fields equals to [u'kid', u'is_visible_in_charlottenburg'] inside init(), but later, inside dump() it gets equal to [u'kid', u'isVisibleInCharlottenburg']. This is the name the field should have in the Json output, but unfortunately it is this list which is passed to the real (item) Serializer, which gets called from the _generate() inside the dump() method.
Therefore the serializer can't map the camelCase field name to the actual name defined in the serializer.

Thanks in advance for fixing it and continue writing good code !
Matt

EDIT: I precise that I'm using the DjangoCollectionSerializer, giving the request as parameter

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions