From 9a30ced90c4e2e28e09f37dd29684c33bf9fcbea Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Sat, 22 Aug 2020 09:58:57 +0200 Subject: [PATCH] Calculates correct map_center for paginated place_list. --- lostplaces/lostplaces_app/models.py | 3 ++- lostplaces/lostplaces_app/views.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index f85b7e5..bcb631a 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -55,10 +55,11 @@ class Place (models.Model): longitude = models.FloatField() description = models.TextField() - # Get center position of all LP-geocoordinates. + # Get center position of LP-geocoordinates. def average_latlon(place_list): amount = len(place_list) + # Init fill values to prevent None longitude = 0 latitude = 0 diff --git a/lostplaces/lostplaces_app/views.py b/lostplaces/lostplaces_app/views.py index 8603934..4a5b894 100644 --- a/lostplaces/lostplaces_app/views.py +++ b/lostplaces/lostplaces_app/views.py @@ -57,8 +57,7 @@ class PlaceListView(IsAuthenticated, ListView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - print(context) - context['place_map_center'] = Place.average_latlon(self.get_queryset()) + context['place_map_center'] = Place.average_latlon(context['place_list']) return context class PlaceDetailView(IsAuthenticated, View):