Skip to content

Should missing dictionary keys be required when serializing mappings. #2342

@tomchristie

Description

@tomchristie

Eg see confusion here: http://stackoverflow.com/questions/27603669/django-rest-framework-3-required-field-behaviour

The 'required=False' flag has always been for if input is required when validating. For output we always require all fields to be present on the object.

For regular object this works fine - even if an attribute is unset, it will at least still exist. With mappings however the key may simply be missing. What's particularly odd here is that input data could successfully validate, but then 'serializer.data' could still raise an error as one of the fields could have been non-required.

Ideally we don't want to silently ignore missing attributes as that's likely to be eg a misnamed field and it shouldn't simply be blank. However for dictionaries, perhaps we should silently skip missing keys on output?

Metadata

Metadata

Assignees

No one assigned

    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