mardi 6 mars 2018

How to subtract two django dates in template

I want to get the number of days between today and a model field end_date. I defined today in my view as shown below. I will then use the number of days to check if its less than or equal to 50 which will add a class to the element

MY TEMPLATE



MY VIEW

if request.user.is_authenticated():
        queryset = Employee.objects.all().order_by('-last_updated')
        today = date.today()
        context = {
        "queryset": queryset,
        "today": today,
        }




Aucun commentaire:

Enregistrer un commentaire