Django Rest Framework ModelSerialzer field doesn't respect required=False -


using django rest framework 3.1.1, have following serializer:

class commentserializer(contentserializer):      created_by = userserializer(required=false)     content = serializers.primarykeyrelatedfield(queryset=content.objects.all(), required=false)      class meta:         model = comment 

while content field respects required=false parameter, created_by not, in result, gives me list of "this field required" validation errors inside userserializer:

{"created_by":{"username":["this field required."],"user_permissions":["this field required."],"password":["this field required."],"groups":["this field required."],"profile_picture":["this field required."]}} 

according documentation section "dealing nested objects" demonstrates usage serializer.

what have tried:

update:

i have created couple of test cases (see here) couldn't replicate issue, looks happening via ajax post.

i added read_only=true created_by field, it's working fine.

class commentserializer(contentserializer):      created_by = userserializer(required=false, read_only=true)     content = serializers.primarykeyrelatedfield(queryset=content.objects.all(), required=false)      class meta:         model = comment 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -