title: How to calculate number of days, when two DateFields are given? Django
body: <p>models.py</p>
  
  <pre><code>from django.db import models
  
  class Leave(models.Model):
      ...
      from_date = models.DateField()
      to_date = models.DateField()
  
      def __str__(self):
          return self.name
  </code></pre>
  
  <p>The above are the two date fields which are defined in my models.py.</p>
  
  <p>views.py</p>
  
  <pre><code>from django.shortcuts import render, render_to_response
  from .forms import LeaveRequestForm
  from django.shortcuts import 
  from .models import Leave
  ...
  def get_days(request):
      data = Leave.objects.all()
      for x in data :
          if x.employee_ID == request.user.username:
              d1 = x.from_date
              d2 = x.to_date
              days = d2 - d1
      return render(request,"status.html", days)
  </code></pre>
  
  <p>The above code is my trial on getting the number of days.</p>
  
  <p>Here, my model is <code>Leave</code> and my form is <code>LeaveRequestForm</code>. In my HTML file to get the number of days I use <code>{{ from_date|timesince:to_date }}</code>, this works but i want to deduct this number of days from a number.</p>
  
  <p>base : I'm working on a leave-management project. If a user asks a leave for 5days and he is eligible for 10days. His balance leaves should be equal to 5.</p>
  
  <p>How do I achieve this with the views?</p>