ugly database fixes, needs improving

This commit is contained in:
Laura Klünder 2023-11-27 22:07:40 +01:00
parent 9ea368f576
commit a2d896fc69
2 changed files with 6 additions and 0 deletions

View file

@ -113,6 +113,9 @@ class GeometryField(models.JSONField):
def get_prep_value(self, value):
if value is None:
return None
if isinstance(value, dict):
# todo: this should also not be needed but whatever
value = shape(value)
self._validate_geomtype(value, exception=TypeError)
if value.is_empty:
raise Exception('Cannot save empty geometry.')

View file

@ -36,6 +36,9 @@ class WrappedGeometry():
wrapped_geojson = None
def __init__(self, geojson):
if isinstance(geojson, str):
# todo: this should not be needed unless the database is fucked
geojson = json.loads(geojson)
self.wrapped_geojson = geojson
@cached_property