From 3994415df2dfecaf14e31b0a181e4e1b42343a0b Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 9 Oct 2019 15:38:48 +0200 Subject: [PATCH] Default to None when using the Serializer as Form for BrowsableAPI --- readthedocs/api/v3/serializers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/readthedocs/api/v3/serializers.py b/readthedocs/api/v3/serializers.py index 992de2cbace..1883327a441 100644 --- a/readthedocs/api/v3/serializers.py +++ b/readthedocs/api/v3/serializers.py @@ -557,8 +557,11 @@ class Meta: def __init__(self, *args, **kwargs): # Initialize the instance with the parent Project to be used in the - # serializer validation. - self.parent_project = kwargs.pop('parent') + # serializer validation. When this Serializer is rendered as a Form in + # BrowsableAPIRenderer, it's not initialized with the ``parent``, so we + # default to ``None`` because we don't need it at that point. + self.parent_project = kwargs.pop('parent', None) + super().__init__(*args, **kwargs) def validate_child(self, value):