Commit d24990ec by Brian Grohe

Fixed many=False issue in related fields

Added check to pop many from kwargs before passing to __init__
Fixed my lint issue from the previous commit
parent 79736e51
...@@ -42,6 +42,8 @@ class RelatedField(Field): ...@@ -42,6 +42,8 @@ class RelatedField(Field):
'Relational fields should not provide a `queryset` argument, ' 'Relational fields should not provide a `queryset` argument, '
'when setting read_only=`True`.' 'when setting read_only=`True`.'
) )
if 'many' in kwargs:
kwargs.pop('many')
super(RelatedField, self).__init__(**kwargs) super(RelatedField, self).__init__(**kwargs)
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
......
...@@ -52,7 +52,7 @@ class TestPrimaryKeyRelatedField(APISimpleTestCase): ...@@ -52,7 +52,7 @@ class TestPrimaryKeyRelatedField(APISimpleTestCase):
field = serializers.PrimaryKeyRelatedField(queryset=self.queryset, many=False) field = serializers.PrimaryKeyRelatedField(queryset=self.queryset, many=False)
instance = field.to_internal_value(self.instance.pk) instance = field.to_internal_value(self.instance.pk)
assert instance is self.instance assert instance is self.instance
class TestProxiedPrimaryKeyRelatedField(APISimpleTestCase): class TestProxiedPrimaryKeyRelatedField(APISimpleTestCase):
def setUp(self): def setUp(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment