diff options
| author | Timo Tuominen | 2014-09-01 17:02:48 +0300 |
|---|---|---|
| committer | Timo Tuominen | 2014-09-01 17:02:48 +0300 |
| commit | e437520217e20d500d641b95482d49484b1f24a7 (patch) | |
| tree | da03f9d15e5312cf7b5f7d269cb2dc011c0db720 | |
| parent | 582f6fdd4b0fb12a7c0d1fefe265499a284c9b79 (diff) | |
| download | django-rest-framework-e437520217e20d500d641b95482d49484b1f24a7.tar.bz2 | |
Generator implementation of class mapping.
| -rw-r--r-- | rest_framework/serializers.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 5c33300c..b3db3582 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -633,11 +633,10 @@ def _get_class_mapping(mapping, obj): from the dictionary or None. """ - for baseclass in inspect.getmro(obj.__class__): - val = mapping.get(baseclass) - if val: - return val - return None + return next( + (mapping[cls] for cls in inspect.getmro(obj.__class__) if cls in mapping), + None + ) class ModelSerializer(Serializer): |
