port to new django, AI automated
This commit is contained in:
@@ -1,26 +1,23 @@
|
||||
from django.forms import fields
|
||||
from location_field.widgets import LocationWidget
|
||||
|
||||
from .widgets import LocationWidget
|
||||
|
||||
|
||||
class PlainLocationField(fields.CharField):
|
||||
"""A form field for entering location data with a map widget."""
|
||||
|
||||
def __init__(self, based_field=None, zoom=None, default=None, *args, **kwargs):
|
||||
|
||||
kwargs['initial'] = default
|
||||
kwargs["initial"] = default
|
||||
self.widget = LocationWidget(based_field=based_field, zoom=zoom, **kwargs)
|
||||
|
||||
dwargs = {
|
||||
'required': True,
|
||||
'label': None,
|
||||
'initial': None,
|
||||
'help_text': None,
|
||||
'error_messages': None,
|
||||
'show_hidden_initial': False,
|
||||
# Extract only the valid kwargs for CharField
|
||||
field_kwargs = {
|
||||
"required": kwargs.get("required", True),
|
||||
"label": kwargs.get("label", None),
|
||||
"initial": kwargs.get("initial", None),
|
||||
"help_text": kwargs.get("help_text", None),
|
||||
"error_messages": kwargs.get("error_messages", None),
|
||||
"show_hidden_initial": kwargs.get("show_hidden_initial", False),
|
||||
}
|
||||
|
||||
for attr in dwargs:
|
||||
if attr in kwargs:
|
||||
dwargs[attr] = kwargs[attr]
|
||||
|
||||
super(PlainLocationField, self).__init__(*args, **dwargs)
|
||||
|
||||
|
||||
super().__init__(*args, **field_kwargs)
|
||||
|
||||
Reference in New Issue
Block a user