summaryrefslogtreecommitdiff
path: root/main/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'main/widgets.py')
-rw-r--r--main/widgets.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/main/widgets.py b/main/widgets.py
index 8e6bd19..4bf95fc 100644
--- a/main/widgets.py
+++ b/main/widgets.py
@@ -24,6 +24,7 @@ Extra widgets and fields
from django import forms
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
+from django.contrib.gis.geos import fromstr
from chimere import settings
from django.contrib.gis.db import models
@@ -180,9 +181,16 @@ onclick='toggleDrawOff();'>%s</div>
tpl += """<script type='text/javascript'><!--
init();"""
if value:
- tpl += """
+ val = value
+ if type(value) == unicode:
+ try:
+ val = fromstr(value)
+ except:
+ pass
+ if hasattr(val, 'json'):
+ tpl += """
var geometry='%s';
-initFeature(geometry);""" % value.json
+initFeature(geometry);""" % val.json
tpl += """
// --></script>
"""