From a439c80cd856f0661cb66003263c454c5108fe0b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 21 Dec 2013 21:21:53 +0000 Subject: Less brittle through relationship testing. Closes #1292. --- rest_framework/serializers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'rest_framework') diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 28a09880..8351b3df 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -713,7 +713,9 @@ class ModelSerializer(Serializer): is_m2m = isinstance(relation.field, models.fields.related.ManyToManyField) - if is_m2m and not relation.field.rel.through._meta.auto_created: + if (is_m2m and + hasattr(relation.field.rel, 'through') and + not relation.field.rel.through._meta.auto_created): has_through_model = True if nested: -- cgit v1.2.3