diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index a6d16fa..d513bb0 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -29,7 +29,7 @@ class Voucher(models.Model): Creation date is being set automatically during voucher creation. """ - code = models.CharField(unique=True, max_length=10) + code = models.CharField(unique=True, max_length=30) created = models.DateTimeField(auto_now_add=True) expires = models.DateField() @@ -63,10 +63,13 @@ class Place (models.Model): longitude = 0 latitude = 0 - for place in place_list: - longitude += place.longitude - latitude += place.latitude - return (latitude / amount, longitude / amount) + if amount > 0: + for place in place_list: + longitude += place.longitude + latitude += place.latitude + return (latitude / amount, longitude / amount) + + return (latitude, longitude) def __str__(self): return self.name