File tree Expand file tree Collapse file tree 4 files changed +9
-33
lines changed Expand file tree Collapse file tree 4 files changed +9
-33
lines changed Original file line number Diff line number Diff line change @@ -147,32 +147,7 @@ from mapbox_location_field.spatial.admin import SpatialMapAdmin
147
147
admin.site.register(SomeLocationModel, SpatialMapAdmin)
148
148
```
149
149
* # ### Admin customization:
150
- Unfortunetly I haven' t found any solution that pass [map_attrs](#map_attrs) automatically from model definition.
151
- The only working way of [customization](# customization) that works in admin panel is overriding the modelform.
152
-
153
- ```python
154
- from django.contrib import admin
155
- from django.forms import ModelForm
156
- from mapbox_location_field.admin import MapAdmin
157
- from mapbox_location_field.forms import LocationField
158
-
159
- from .models import SomeLocationModel
160
-
161
-
162
- class PlaceForm(ModelForm):
163
- class Meta:
164
- model = Place fields = " __all__"
165
- location = LocationField(map_attrs = {" style" : " mapbox://styles/mapbox/satellite-v9" })
166
-
167
-
168
- class MyMapAdmin(MapAdmin):
169
- form = PlaceForm
170
-
171
- admin.site.register(SomeLocationModel, MyMapAdmin)
172
- ```
173
- For spatial field replace the `mapbox_location_field.admin.MapAdmin` with the `mapbox_location_field.spatial.admin.SpatialMapAdmin` and the `mapbox_location_field.forms.LocationField` with `mapbox_location_field.spatial.forms.LocationField`
174
-
175
- In examples above, `SomeLocationModel` is name of your model, like in [usage section](# usage).
150
+ Since `v1.7.0` admin customization should work out of the box, automatically using the `map_attrs` from model definition.
176
151
177
152
# AddressAutoHiddenField
178
153
AddressAutoHiddenField is field for storing address. It uses AddressAutoHiddenInput which is hidden and when you place your marker on map , automatically fill itself with proper address.
Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ class LocationField(forms.CharField):
44
44
45
45
def __init__ (self , * args , ** kwargs ):
46
46
map_attrs = kwargs .pop ("map_attrs" , None )
47
- self .widget = MapInput (map_attrs = map_attrs , )
48
-
49
47
super ().__init__ (* args , ** kwargs )
48
+
49
+ self .widget = MapInput (map_attrs = map_attrs , )
50
50
self .error_messages = {"required" : "Please pick a location, it's required" , }
51
51
52
52
def to_python (self , value ):
@@ -59,6 +59,7 @@ class AddressAutoHiddenField(forms.CharField):
59
59
60
60
def __init__ (self , * args , ** kwargs ):
61
61
map_id = kwargs .pop ("map_id" , "map" )
62
- self .widget = AddressAutoHiddenInput (map_id = map_id )
63
62
super ().__init__ (* args , ** kwargs )
63
+
64
+ self .widget = AddressAutoHiddenInput (map_id = map_id )
64
65
self .label = ""
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ class SpatialLocationField(PointField):
10
10
11
11
def __init__ (self , * args , ** kwargs ):
12
12
map_attrs = kwargs .pop ("map_attrs" , None )
13
- self .widget = MapInput (map_attrs = map_attrs , )
14
-
15
13
super ().__init__ (* args , ** kwargs )
14
+
15
+ self .widget = MapInput (map_attrs = map_attrs , )
16
16
self .error_messages = {"required" : "Please pick a location, it's required" , }
17
17
18
18
def clean (self , value ):
Original file line number Diff line number Diff line change 10
10
11
11
setup (
12
12
name = 'django-mapbox-location-field' ,
13
- version = '1.6.4 ' ,
13
+ version = '1.7.0 ' ,
14
14
packages = ["mapbox_location_field" ],
15
15
include_package_data = True ,
16
16
license = 'MIT License' ,
17
17
description = 'location field with MapInput widget for picking some location' ,
18
18
long_description = README ,
19
19
long_description_content_type = "text/markdown" ,
20
- download_url = "https://github.com/Simon-the-Shark/django-mapbox-location-field/archive/v1.6.4 .tar.gz" ,
20
+ download_url = "https://github.com/Simon-the-Shark/django-mapbox-location-field/archive/v1.7.0 .tar.gz" ,
21
21
url = 'https://github.com/Simon-the-Shark/django-mapbox-location-field' ,
22
22
author = 'Szymon Kowaliński' ,
23
23
You can’t perform that action at this time.
0 commit comments