Ticket #5438: proxy_newmodel_none.patch
File proxy_newmodel_none.patch, 1.6 KB (added by , 17 years ago) |
---|
-
django/contrib/gis/db/models/proxy.py
19 19 # Getting the value of the field. 20 20 geom_value = obj.__dict__[self._field.attname] 21 21 22 if (geom_value is None) or (isinstance(geom_value, GEOSGeometry)):22 if isinstance(geom_value, GEOSGeometry): 23 23 # If the value of the field is None, or is already a GEOS Geometry 24 24 # no more work is needed. 25 geom = geom_value 25 geom = geom_value 26 elif (geom_value is None) or (geom_value==''): 27 geom = None 26 28 else: 27 29 # Otherwise, a GEOSGeometry object is built using the field's contents, 28 30 # and the model's corresponding attribute is set. -
django/contrib/gis/tests/geoapp/tests.py
256 256 self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, 'T********')).name) 257 257 self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, 'T********')).name) 258 258 259 def test16_createnull(self): 260 "Testing creating a model instance and the geometry being None" 261 c = City() 262 self.assertEqual(c.point, None) 263 259 264 def suite(): 260 265 s = unittest.TestSuite() 261 266 s.addTest(unittest.makeSuite(GeoModelTest))