Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using NestedField with accept_pk kwarg can only accepted JSON input but not form-data input #194

Open
caesarleong opened this issue Dec 30, 2020 · 0 comments

Comments

@caesarleong
Copy link

caesarleong commented Dec 30, 2020

I got empty field if I use form-data input when apply NestedField. It seems NestedField only support JSON input. I add some log into DRF native serializers.py's to_internal_value() and I got below log with different format input

        print('data: {}'.format(data))
        for field in fields:
            validate_method = getattr(self, 'validate_' + field.field_name, None)
            print('field: {}'.format(field))
            primitive_value = field.get_value(data)
            print('key: {}, value: {}'.format(field.field_name, primitive_value))

data: <QueryDict: {'name': ['player04'], 'merchant': ['1']}>
field: NestedField(MerchantSerializer, many=False)
key: merchant, value: <class 'rest_framework.fields.empty'>

data: {'merchant': 1, 'name': 'PlayerJson01'}
field: NestedField(MerchantSerializer, many=False)
key: merchant, value: 1

Hope NestedField can support form-data as well, Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant