How to Get Min Value from Django List?
Published On: 18/08/2022 | Category:
Django

Hi Dev,
In this post, we will learn django get min value from list. you can understand a concept of django list find min value. you will learn django list get min value index example. This tutorial will give you simple example of django find min value in list of objects.
There are a few ways to get the lowest number from the list in django. i will give you two examples using for loop with min() to get min number from list. so let's see the below examples.
You can use these examples with django3 (Django 3) version.
let's see below a simple example with output:
Example : 1 views.pyfrom django.shortcuts import render from django.http import HttpResponse def index(request): myList = [10, 100, 20, 200, 50] # Get Min number from List minValue = min(myList) print(minValue) return HttpResponse(minValue)Output
10Example : 2 views.py
from django.shortcuts import render from django.http import HttpResponse def index(request): myList = [10, 100, 20, 200, 50] # Get Max number from List myList.sort() minValue = myList[0] print(minValue) return HttpResponse(minValue)Output
10
I Hope It will help you....