Hi I have a Django function:
def get_spans(angle):
spans = Spans.objects.values_list('span').filter(
max_roof_angle=angle,
)
try:
max_span = max(spans)
except ValueError:
max_span = 0
return max_span
My question is – why does this return a tuple? How do I ensure I am getting a single, integer value back?
Any help much appreciated.
From the documentation: you can get a flat list using the arg flat=True. If you try to get the max from a list you would get a single value which you need