From 8c7b5fc5c132ee4648aef7e95868dec9064d8ef6 Mon Sep 17 00:00:00 2001 From: "S. Andrew Sheppard" Date: Wed, 27 May 2015 21:14:08 -0500 Subject: [PATCH] pop required extra_kwargs if read_only is set --- rest_framework/serializers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 8e1e50bc7..b1d58ee5f 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -1088,6 +1088,9 @@ class ModelSerializer(Serializer): if extra_kwargs.get('default') and kwargs.get('required') is False: kwargs.pop('required') + if kwargs.get('read_only', False): + extra_kwargs.pop('required', None) + kwargs.update(extra_kwargs) return kwargs