replaced len with count() on a few queries
This commit is contained in:
@@ -364,7 +364,7 @@ class Team(models.Model):
|
||||
|
||||
if manager.rower.rowerplan in ['plan','pro']:
|
||||
otherteams = Team.objects.filter(manager=manager)
|
||||
if len(otherteams) >= 1:
|
||||
if otherteams.count() >= 1:
|
||||
raise ValidationError(
|
||||
"Pro and Self-Coach users cannot have more than one team"
|
||||
)
|
||||
@@ -569,7 +569,7 @@ def course_length(course):
|
||||
if not polygons:
|
||||
return 0
|
||||
|
||||
for i in range(len(polygons)-1):
|
||||
for i in range(polygons.count()-1):
|
||||
latitude1,longitude1 = polygon_coord_center(polygons[i])
|
||||
latitude2,longitude2 = polygon_coord_center(polygons[i+1])
|
||||
|
||||
@@ -656,7 +656,7 @@ class CoachingGroup(models.Model):
|
||||
|
||||
def __len__(self):
|
||||
rs = Rower.objects.filter(coachinggroups__in=[self])
|
||||
return len(rs)
|
||||
return rs.count()
|
||||
|
||||
# Extension of User with rowing specific data
|
||||
@python_2_unicode_compatible
|
||||
@@ -3133,7 +3133,7 @@ def auto_delete_image_on_delete(sender,instance, **kwargs):
|
||||
if instance.filename:
|
||||
if os.path.isfile(instance.filename):
|
||||
others = GraphImage.objects.filter(filename=instance.filename)
|
||||
if len(others) == 0:
|
||||
if others.count() == 0:
|
||||
os.remove(instance.filename)
|
||||
else:
|
||||
print("couldn't find the file "+instance.filename)
|
||||
|
||||
Reference in New Issue
Block a user