From d44bf0c0f2ab8dec09b92b386ea572dae17e216a Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Sat, 22 Aug 2020 09:24:50 +0200 Subject: [PATCH] Customized PlaceListView to provide data for map rendering. --- lostplaces/lostplaces_app/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lostplaces/lostplaces_app/views.py b/lostplaces/lostplaces_app/views.py index 20e4f03..8603934 100644 --- a/lostplaces/lostplaces_app/views.py +++ b/lostplaces/lostplaces_app/views.py @@ -55,6 +55,12 @@ class PlaceListView(IsAuthenticated, ListView): template_name = 'place/place_list.html' ordering = ['name'] + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + print(context) + context['place_map_center'] = Place.average_latlon(self.get_queryset()) + return context + class PlaceDetailView(IsAuthenticated, View): def get(self, request, pk): place = Place.objects.get(pk=pk)