Permalink
Browse files

fix bug where empty string was passed to GEOSGeometry()

  • Loading branch information...
1 parent 6a74a31 commit cfd109ce70098ea7f3f6c4829eff379688674d87 Justine Tunney committed Aug 29, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 rideshare/forms.py
View
10 rideshare/forms.py
@@ -8,6 +8,7 @@
"""
from django import forms
+from django.contrib.gis.geos import GEOSGeometry
from rideshare import models as db
@@ -46,12 +47,13 @@ def __init__(self, *args, **kwargs):
self.initial['waypoints'] = '\n'.join(instance.waypoint_list[1:-1])
def save(self, commit=True):
- from django.contrib.gis.geos import GEOSGeometry
model = super(RideForm, self).save(commit=False)
- points = GEOSGeometry(self.cleaned_data['waypoints_points_wkt'])
- #pdb.set_trace()
- model.waypoints_points = points
+ if self.cleaned_data['waypoints_points_wkt']:
+ points = GEOSGeometry(self.cleaned_data['waypoints_points_wkt'])
+ model.waypoints_points = points
+ else:
+ model.waypoints_points = None
if self.cleaned_data['waypoints'] != '':
self.cleaned_data['waypoints'] = \

0 comments on commit cfd109c

Please sign in to comment.