Customized PlaceListView to provide data for map rendering.

This commit is contained in:
Marcus Scholz 2020-08-22 09:24:50 +02:00
parent cad53c070c
commit d44bf0c0f2

View File

@ -55,6 +55,12 @@ class PlaceListView(IsAuthenticated, ListView):
template_name = 'place/place_list.html' template_name = 'place/place_list.html'
ordering = ['name'] 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): class PlaceDetailView(IsAuthenticated, View):
def get(self, request, pk): def get(self, request, pk):
place = Place.objects.get(pk=pk) place = Place.objects.get(pk=pk)