From c3e2d3967d02ddf4aed870f1ef0c9dfe2844298c Mon Sep 17 00:00:00 2001 From: jerel Date: Fri, 29 Apr 2016 12:30:49 -0500 Subject: [PATCH] Fixes #230. Keep write only fields from having an attribute key --- rest_framework_json_api/renderers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework_json_api/renderers.py b/rest_framework_json_api/renderers.py index 93285f05..0f33b69c 100644 --- a/rest_framework_json_api/renderers.py +++ b/rest_framework_json_api/renderers.py @@ -43,6 +43,9 @@ def extract_attributes(fields, resource): # ID is always provided in the root of JSON API so remove it from attributes if field_name == 'id': continue + # don't output a key for write only fields + if fields[field_name].write_only: + continue # Skip fields with relations if isinstance(field, (relations.RelatedField, relations.ManyRelatedField, BaseSerializer)): continue