In the view, form a query with data truncation and transfer to the template, then in the template output the data of this sample.
For example:
# models.py class Parking(models.Model): timestamp = models.DateTimeField(auto_now=True) car_number = models.CharField(max_length = 15) parking_position = models.CharField(max_length = 5) # views.py def cars_on_parking(request): cars = Parking.objects.all().order_by('-timestamp')[:5] .... .... order_by('-timestamp') - сортировка по полю timestamp. в обратном порядке [:5] - усечение данных в запросе, т.е. взять 5 записей из запроса.
Then in the cars variable there will be information about the last 5 entries from the Parking model.
You can also use reverse () for the request instead of order_by ('- timestamp')
You can read about reverse () the following link: https://docs.djangoproject.com/en/2.0/ref/models/querysets/#reverse