2013-09-22 11:11:48 +02:00
|
|
|
from django.forms import fields
|
|
|
|
from location_field.widgets import LocationWidget
|
|
|
|
|
|
|
|
|
|
|
|
class PlainLocationField(fields.CharField):
|
2013-09-27 11:39:28 +02:00
|
|
|
def __init__(self, based_field=None, zoom=None, default=None, *args, **kwargs):
|
|
|
|
|
2013-09-22 11:11:48 +02:00
|
|
|
kwargs['initial'] = default
|
2013-09-27 11:39:28 +02:00
|
|
|
self.widget = LocationWidget(based_field=based_field, zoom=zoom, **kwargs)
|
2013-09-22 11:11:48 +02:00
|
|
|
|
|
|
|
dwargs = {
|
|
|
|
'required': True,
|
|
|
|
'label': None,
|
|
|
|
'initial': None,
|
|
|
|
'help_text': None,
|
|
|
|
'error_messages': None,
|
|
|
|
'show_hidden_initial': False,
|
|
|
|
}
|
|
|
|
|
|
|
|
for attr in dwargs:
|
|
|
|
if attr in kwargs:
|
|
|
|
dwargs[attr] = kwargs[attr]
|
|
|
|
|
|
|
|
super(PlainLocationField, self).__init__(*args, **dwargs)
|
|
|
|
|
|
|
|
|