diff options
| author | Justin Bronn <jbronn@gmail.com> | 2007-09-14 22:56:43 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2007-09-14 22:56:43 +0000 |
| commit | 483a807c063e24f09ecf5ce74d1e241f4c81368c (patch) | |
| tree | 941570b5a0ef60204858403d8e7653a41b33b7a3 | |
| parent | d1d5cf7aa266cc04592e5f122563ae6315870050 (diff) | |
gis: Fixed #5438 with patches from rcoup.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6243 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/gis/db/models/proxy.py | 6 | ||||
| -rw-r--r-- | django/contrib/gis/tests/geoapp/tests.py | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/django/contrib/gis/db/models/proxy.py b/django/contrib/gis/db/models/proxy.py index e8fbb87bd4..65c613da26 100644 --- a/django/contrib/gis/db/models/proxy.py +++ b/django/contrib/gis/db/models/proxy.py @@ -19,10 +19,12 @@ class GeometryProxy(object): # 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 else: # Otherwise, a GEOSGeometry object is built using the field's contents, # and the model's corresponding attribute is set. diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index e7f140dc0d..f94fd73124 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -256,6 +256,11 @@ class GeoModelTest(unittest.TestCase): 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() s.addTest(unittest.makeSuite(GeoModelTest)) |
