ugly database fixes, needs improving
This commit is contained in:
parent
9ea368f576
commit
a2d896fc69
2 changed files with 6 additions and 0 deletions
|
@ -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.')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue