aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2014-12-05 14:00:59 +0000
committerTom Christie2014-12-05 14:00:59 +0000
commitc611a2c1fe7370bbe3151cb04b546e3e400acf1e (patch)
tree83f64814636e23fca5e9006ad3597bac5a45a2d0 /rest_framework
parentfca91750293d2a1ef6f4f7e8bf5dad009df5a935 (diff)
parentd68c61450440a522b08b64fdd21028cc739e6ead (diff)
downloaddjango-rest-framework-c611a2c1fe7370bbe3151cb04b546e3e400acf1e.tar.bz2
Merge pull request #2213 from BrickXu/master
Raise error if `fields` on serializer is not a list of strings.
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/serializers.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index c022cad3..8784b303 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -794,6 +794,12 @@ class ModelSerializer(Serializer):
depth = getattr(self.Meta, 'depth', 0)
extra_kwargs = getattr(self.Meta, 'extra_kwargs', {})
+ if fields and not isinstance(fields, (list, tuple)):
+ raise TypeError('`fields` must be a list or tuple')
+
+ if exclude and not isinstance(exclude, (list, tuple)):
+ raise TypeError('`exclude` must be a list or tuple')
+
assert not (fields and exclude), "Cannot set both 'fields' and 'exclude'."
extra_kwargs = self._include_additional_options(extra_kwargs)