Skip to content

Commit

Permalink
Gracefully handle [null, null] for GeoPointField value
Browse files Browse the repository at this point in the history
In case you need to set coordinates to null this would be useful
  • Loading branch information
gregor2004ua authored Dec 14, 2017
1 parent d4a13e3 commit 33d88b6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rest_framework_mongoengine/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 33d88b6

Please sign in to comment.