Addressbook
- location field.. has to be refactored
This commit is contained in:
28
location_field/forms.py
Normal file
28
location_field/forms.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from django.forms import fields
|
||||
from location_field.widgets import LocationWidget
|
||||
|
||||
|
||||
class PlainLocationField(fields.CharField):
|
||||
def __init__(self, based_fields=None, zoom=None, default=None,
|
||||
*args, **kwargs):
|
||||
kwargs['initial'] = default
|
||||
|
||||
self.widget = LocationWidget(based_fields=based_fields, zoom=zoom,
|
||||
**kwargs)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user