wagtail-geo-widget
wagtail-geo-widget copied to clipboard
GEO_WIDGET_DEFAULT_LOCATION without touching the field returns None
Expected result would be that GEO_WIDGET_DEFAULT_LOCATION
are set.
Description from user:
I just had to manually set the default location, by overriding the save method. I tried to set:GEO_WIDGET_DEFAULT_LOCATION = {'lat': 45.070312, 'lng': 7.6868565} but when I save the model without touching the location, the location field is set to None (maybe I did something wrong, but with 3 lines of code in the save model I solved the problem).
I tracked this down and this has been the default behavior from the beginning. I can see the use of storing the default value in the field, no matter if map is touched or not. But I can also see the use of having a None value if untouched, as to indicate the map value has not yet been filled. My plan is this:
Current solution
-
GEO_WIDGET_DEFAULT_LOCATION
only effect what the map widget should show, but user interaction is required for the value to be saved, If not touched,None
are stored.
New behavior
-
GEO_WIDGET_DEFAULT_LOCATION
behavior are left unchanged, it only effects the map display. - A new setting
GEO_WIDGET_SAVE_DEFAULT_LOCATION
is introduced to avoid breaking changes, itsFalse
by default. Setting it toTrue
will also save the default location as a field value as well.