Remove Time in Date

Please show me how to remove the time in date.
I am getting this output in my template: 114 days, 0:00:00
My prefer output is just 114 without the 0:00:00.

Below is the code:

models.py:
class Server(models.Model):
  server_name = models.CharField(unique=True, max_length=30)
  server_warrantyexpiry = models.DateField(auto_now=False, auto_now_add=False)

  def daysleft(self):
    today = date.today()
    daysleft = self.server_warrantyexpiry - today
    return daysleft

template:
          {% for server in server_list %}
          <tr>
            <td>{{ server.server_name }}</td>
            <td>{{ server.daysleft }}</td>
          </tr>

Subtracting two date fields creates a timedelta object. Unfortunately, there’s no Python built-in function to format a timedelta.

As an off-the-cuff idea, there are two solutions I can think of off-hand.

  • Use the days function on the value and concatenate the word “days” yourself. e.g., <td>{{ server.daysleft.days }} days</td>

  • Alter the view to create it directly. e.g., daysleft = (self.expiry - today).days and render it as above.

As always thanks Ken.