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):