Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

gis: Fixed #5438 with patches from rcoup.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 483a807c063e24f09ecf5ce74d1e241f4c81368c 1 parent d1d5cf7
@jbronn jbronn authored
6 django/contrib/gis/db/models/
@@ -19,10 +19,12 @@ def __get__(self, obj, type=None):
# Getting the value of the field.
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
# no more work is needed.
- geom = geom_value
+ geom = geom_value
+ elif (geom_value is None) or (geom_value==''):
+ geom = None
# Otherwise, a GEOSGeometry object is built using the field's contents,
# and the model's corresponding attribute is set.
5 django/contrib/gis/tests/geoapp/
@@ -256,6 +256,11 @@ def test15_relate(self):
self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, '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():
s = unittest.TestSuite()
Please sign in to comment.
Something went wrong with that request. Please try again.