Code

Ticket #10872: geodjango_widget_list_editable_support2.patch

File geodjango_widget_list_editable_support2.patch, 1.9 KB (added by springmeyer, 5 years ago)

New patch to solve problem more cleanly using the widget attr 'name'

  • django/contrib/gis/admin/widgets.py

     
    3737 
    3838        # Constructing the dictionary of the map options. 
    3939        self.params['map_options'] = self.map_options() 
    40  
    41         # Constructing the JavaScript module name using the ID of 
     40         
     41         
     42        # Constructing the JavaScript module name using the name of 
    4243        # the GeometryField (passed in via the `attrs` keyword). 
    43         self.params['module'] = 'geodjango_%s' % self.params['field_name'] 
     44        # Use the 'name' attr for the field name (rather than 'field') 
     45        self.params['name'] = name 
     46        # note: we must switch out dashes for underscores since js 
     47        # functions are created using the module variable 
     48        js_safe_name = self.params['name'].replace('-','_') 
    4449 
     50        self.params['module'] = 'geodjango_%s' % js_safe_name 
     51 
    4552        if value: 
    4653            # Transforming the geometry to the projection used on the 
    4754            # OpenLayers map. 
  • django/contrib/gis/templates/gis/admin/openlayers.html

     
    3232<div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div> 
    3333<a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a> 
    3434{% if display_wkt %}<p> WKT debugging window:</p>{% endif %} 
    35 <textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ field_name }}">{{ wkt }}</textarea> 
     35<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ name }}">{{ wkt }}</textarea> 
    3636<script type="text/javascript">{% block init_function %}{{ module }}.init();{% endblock %}</script> 
    3737</span>