MCPcopy
hub / github.com/django/django / has_changed

Method has_changed

django/contrib/gis/forms/fields.py:94–112  ·  view source on GitHub ↗

Compare geographic value of data with its initial value.

(self, initial, data)

Source from the content-addressed store, hash-verified

92 return geom
93
94 def has_changed(self, initial, data):
95 """Compare geographic value of data with its initial value."""
96
97 try:
98 data = self.to_python(data)
99 initial = self.to_python(initial)
100 except ValidationError:
101 return True
102
103 # Only do a geographic comparison if both values are available
104 if initial and data:
105 data.transform(initial.srid)
106 # If the initial value was not added by the browser, the geometry
107 # provided may be slightly different, the first time it is saved.
108 # The comparison is done with a very low tolerance.
109 return not initial.equals_exact(data, tolerance=0.000001)
110 else:
111 # Check for change of state of existence
112 return bool(initial) != bool(data)
113
114
115class GeometryCollectionField(GeometryField):

Callers

nothing calls this directly

Calls 3

to_pythonMethod · 0.95
equals_exactMethod · 0.80
transformMethod · 0.45

Tested by

no test coverage detected