1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

gis: Fixed #5438 with patches from rcoup.

git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6243 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Justin Bronn 2007-09-14 22:56:43 +00:00
parent d1d5cf7aa2
commit 483a807c06
2 changed files with 9 additions and 2 deletions

View File

@ -19,10 +19,12 @@ class GeometryProxy(object):
# Getting the value of the field. # Getting the value of the field.
geom_value = obj.__dict__[self._field.attname] geom_value = obj.__dict__[self._field.attname]
if (geom_value is None) or (isinstance(geom_value, GEOSGeometry)): if isinstance(geom_value, GEOSGeometry):
# If the value of the field is None, or is already a GEOS Geometry # If the value of the field is None, or is already a GEOS Geometry
# no more work is needed. # no more work is needed.
geom = geom_value geom = geom_value
elif (geom_value is None) or (geom_value==''):
geom = None
else: else:
# Otherwise, a GEOSGeometry object is built using the field's contents, # Otherwise, a GEOSGeometry object is built using the field's contents,
# and the model's corresponding attribute is set. # and the model's corresponding attribute is set.

View File

@ -256,6 +256,11 @@ class GeoModelTest(unittest.TestCase):
self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, 'T********')).name) self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, 'T********')).name)
self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, 'T********')).name) self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, 'T********')).name)
def test16_createnull(self):
"Testing creating a model instance and the geometry being None"
c = City()
self.assertEqual(c.point, None)
def suite(): def suite():
s = unittest.TestSuite() s = unittest.TestSuite()
s.addTest(unittest.makeSuite(GeoModelTest)) s.addTest(unittest.makeSuite(GeoModelTest))