We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d88e9d5 commit fda808aCopy full SHA for fda808a
basic/tools/templatetags/numtuils.py
@@ -0,0 +1,27 @@
1
+from django.template import Library
2
+
3
+register = Library()
4
5
6
+@register.filter
7
+def min(object_list, field):
8
+ """
9
+ Returns the min value given an object_list and a field.
10
11
+ Example:
12
+ {{ forecast|min:"high_temp" }}
13
14
+ value_list = [getattr(o, obj, None) for o in object_list]
15
+ return min(value_list)
16
17
18
19
+def max(object_list, field):
20
21
+ Returns the max value given an object_list and a field.
22
23
24
+ {{ forecast|max:"high_temp" }}
25
26
27
+ return max(value_list)
0 commit comments