Calculates correct map_center for paginated place_list.

This commit is contained in:
Marcus Scholz 2020-08-22 09:58:57 +02:00
parent d44bf0c0f2
commit 9a30ced90c
2 changed files with 3 additions and 3 deletions

View File

@ -55,10 +55,11 @@ class Place (models.Model):
longitude = models.FloatField() longitude = models.FloatField()
description = models.TextField() description = models.TextField()
# Get center position of all LP-geocoordinates. # Get center position of LP-geocoordinates.
def average_latlon(place_list): def average_latlon(place_list):
amount = len(place_list) amount = len(place_list)
# Init fill values to prevent None
longitude = 0 longitude = 0
latitude = 0 latitude = 0

View File

@ -57,8 +57,7 @@ class PlaceListView(IsAuthenticated, ListView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
print(context) context['place_map_center'] = Place.average_latlon(context['place_list'])
context['place_map_center'] = Place.average_latlon(self.get_queryset())
return context return context
class PlaceDetailView(IsAuthenticated, View): class PlaceDetailView(IsAuthenticated, View):