Commits

Nathan Duthoit  committed 39220e6

Added replacement for the MapWidget for the Admin that only worked when Address was a non-abstract model

  • Participants
  • Parent commits 741a24c

Comments (0)

Files changed (2)

File easy_maps/admin.py

     list_display = ['address', 'computed_address', 'latitude', 'longitude', 'geocode_error']
     list_filter = ['geocode_error']
     search_fields = ['address']
+
+    change_form_template = 'admin/easy_maps/easy_maps_change_form.html'
+
+    def change_view(self, request, object_id, extra_context=None):
+        my_context = {
+            'address_instance': self.model.objects.get(id=object_id),
+        }
+        return super(AddressAdmin, self).change_view(request, object_id,
+                                                     extra_context=my_context)

File easy_maps/templates/admin/easy_maps/easy_maps_change_form.html

+{% extends "admin/change_form.html" %}
+{% load easy_maps_tags %}
+{% load i18n %}
+{% block after_field_sets %}
+    <div id="easy_map" class="module aligned">
+    <h2>{% trans "Map" %}</h2>
+    {% easy_map address_instance 700 200 16 %}
+    </div>
+{% endblock %}