From d60ecfc4982ff5ccfacd285404fc54e3e0fd6567 Mon Sep 17 00:00:00 2001 From: Tymur Maryokhin Date: Thu, 18 Dec 2014 16:03:15 +0100 Subject: [PATCH] Assert fields in `exclude` are model fields --- rest_framework/serializers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 8de22f4b9f..ed709d848b 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -880,6 +880,10 @@ def get_fields(self): exclude = getattr(self.Meta, 'exclude', None) if exclude is not None: for field_name in exclude: + assert field_name in fields, ( + 'The field in the `exclude` option must be a model field. Got %s.' % + field_name + ) fields.remove(field_name) # Determine the set of model fields, and the fields that they map to. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy