From 179964eef8132844d7d2c49639ed7b33a4b694f3 Mon Sep 17 00:00:00 2001 From: Lucas Lavandeira <19612265+lucaslavandeira@users.noreply.github.com> Date: Mon, 3 Dec 2018 10:25:25 -0300 Subject: [PATCH] Formateo la fecha adecuadamente de AnalyticsImportTask mejora la legibilidad en el admin de django --- series_tiempo_ar_api/apps/analytics/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/series_tiempo_ar_api/apps/analytics/models.py b/series_tiempo_ar_api/apps/analytics/models.py index 90a62ecd..5e662294 100644 --- a/series_tiempo_ar_api/apps/analytics/models.py +++ b/series_tiempo_ar_api/apps/analytics/models.py @@ -7,6 +7,7 @@ from django.conf import settings from django.db import models from django.core.exceptions import ValidationError +from django.utils import timezone from solo.models import SingletonModel from series_tiempo_ar_api.apps.management.models import TaskCron @@ -73,6 +74,7 @@ def save(self, *args, **kwargs): class AnalyticsImportTask(models.Model): + DATE_FORMAT = '%Y-%m-%d %H:%M:%S' RUNNING = 'running' FINISHED = 'finished' @@ -87,7 +89,7 @@ class AnalyticsImportTask(models.Model): timestamp = models.DateTimeField() def __str__(self): - return "Analytics import task at {}".format(self.timestamp) + return "Analytics import task at {}".format(self._format_date(self.timestamp)) def write_logs(self, text): if not self.logs: @@ -95,3 +97,6 @@ def write_logs(self, text): self.logs += text + '\n' self.save() + + def _format_date(self, date): + return timezone.localtime(date).strftime(self.DATE_FORMAT)