From 8f7a6481f8273b0baec19c927b9f2f3c53bb9bdf Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 30 Nov 2015 12:29:01 -0200 Subject: [PATCH] Change date format in list and datails view --- sapl/crud.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sapl/crud.py b/sapl/crud.py index 5340c0ffe..dec5888d4 100644 --- a/sapl/crud.py +++ b/sapl/crud.py @@ -1,5 +1,6 @@ from braces.views import FormMessagesMixin from crispy_forms.helper import FormHelper +from datetime import datetime from django import forms from django.conf.urls import url from django.core.urlresolvers import reverse, reverse_lazy @@ -51,7 +52,13 @@ def get_field_display(obj, fieldname): value = getattr(obj, 'get_%s_display' % fieldname)() else: value = getattr(obj, fieldname) - display = '' if value is None else str(value) + if value is None: + display = '' + elif 'date' in str(type(value)): + display = value.strftime("%d/%m/%Y") + else: + display = str(value) + return verbose_name, display