-
Notifications
You must be signed in to change notification settings - Fork 8
/
forms.py
executable file
·32 lines (23 loc) · 1.07 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from django.forms import widgets
from django.template import Context, loader
from conf import settings
#===============================================================================
# Avoid jQuery to be loaded twice if it's there
#===============================================================================
class GoogleMapsFormWidget(widgets.Widget):
class Media:
js = ('http://maps.google.com/maps/api/js?sensor=true',
settings.GMAP_JQUERY,
settings.GMAP_JQUERY_UI,
settings.STATIC_URL + 'admin/gmapsfield/admin.js',
settings.STATIC_URL + 'admin/gmapsfield/json2.js',)
css = {
'all': (settings.GMAP_JQUERY_UI_CSS,),
}
def __init__(self, *args, **kwargs):
super(GoogleMapsFormWidget, self).__init__(*args, **kwargs)
self.inner_widget = widgets.HiddenInput()
def render(self, name, value, *args, **kwargs):
template = loader.get_template("admin.html")
context = Context({ "name": name, "value": value })
return template.render(context)