mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #25673 -- Made GeometryField.from_db_value
set SRID
This commit is contained in:
parent
f98126a05a
commit
5f7035cec7
@ -257,8 +257,12 @@ class GeometryField(GeoSelectFormatMixin, BaseSpatialField):
|
||||
return geom
|
||||
|
||||
def from_db_value(self, value, expression, connection, context):
|
||||
if value and not isinstance(value, Geometry):
|
||||
value = Geometry(value)
|
||||
if value:
|
||||
if not isinstance(value, Geometry):
|
||||
value = Geometry(value)
|
||||
srid = value.srid
|
||||
if not srid and self.srid != -1:
|
||||
value.srid = self.srid
|
||||
return value
|
||||
|
||||
def get_srid(self, geom):
|
||||
|
@ -893,3 +893,7 @@ class GeoQuerySetTest(TestCase):
|
||||
def test_non_concrete_field(self):
|
||||
NonConcreteModel.objects.create(point=Point(0, 0), name='name')
|
||||
list(NonConcreteModel.objects.all())
|
||||
|
||||
def test_values_srid(self):
|
||||
for c, v in zip(City.objects.all(), City.objects.values()):
|
||||
self.assertEqual(c.point.srid, v['point'].srid)
|
||||
|
Loading…
Reference in New Issue
Block a user