From 33d88b623077936c54b5f0d5a66def4443941819 Mon Sep 17 00:00:00 2001 From: Igor Kachmaryk Date: Wed, 13 Dec 2017 22:15:56 -0500 Subject: [PATCH] Gracefully handle [null, null] for GeoPointField value In case you need to set coordinates to null this would be useful --- rest_framework_mongoengine/fields.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_framework_mongoengine/fields.py b/rest_framework_mongoengine/fields.py index 8d01860..cbca88f 100644 --- a/rest_framework_mongoengine/fields.py +++ b/rest_framework_mongoengine/fields.py @@ -445,6 +445,8 @@ def to_internal_value(self, value): self.fail('not_a_list', input_value=repr(value)) if len(value) != 2: self.fail('not_2d', input_value=repr(value)) + if value == [None, None]: + return value try: return [float(value[0]), float(value[1])] except ValueError: