https://docs.djangoproject.com/en/3.0/howto/custom-template-tags/
mira bien aqui tu pudes facbicarte uno para separara la hora y la devuelves a la vista en tiempo de ejecucion osea cuando se renderiza tu pagina creas un archivo y lo instancias {% tag_template_name args kwars %} puedes tomar el string y devover lo que quieras que se renderize
un ujeplo de archivo
from django import template
from django.utils import timezone
from datetime import timedelta, date
register = template.Library()
@register.filter
def to_and(value):
value = str(value)
return value.replace(",",".")
@register.filter
def many_days(value):
today = timezone.localtime()
fecha = value - today
if fecha.days >= 0:
if fecha.days == 0:
fecha = 'Llegan Hoy'
else:
fecha = "Quedan :"+str(fecha.days)+' Dias y '+str(((str(fecha).split(','))[1].split('.')[0]))+" h/mm"
else:
fecha = value
return fecha
El jue., 23 ene. 2020 a las 21:22, DANIEL URBANO DE LA RUA (<dannybombastic@gmail.com>) escribió:
Create un tag template espera te mando docOn Thu, 23 Jan 2020, 19:38 Tatiana Mesa, <tatianamesa687@gmail.com> wrote:Hola Daniel, gracias por la rápida respuestaTengo el campo DateTimeField que trae la fecha y la hora en el mismo campo. Quiero separarlos solo en la vista del Html. Sin modificar el tipo de dato.Agradezco tu respuesta.--El jue., 23 de ene. de 2020 a la(s) 12:27, DANIEL URBANO DE LA RUA (dannybombastic@gmail.com) escribió:--El jue., 23 ene. 2020 a las 18:24, DANIEL URBANO DE LA RUA (<dannybombastic@gmail.com>) escribió:El jue., 23 ene. 2020 a las 18:19, DANIEL URBANO DE LA RUA (<dannybombastic@gmail.com>) escribió:Tienes date and time fieldOn Thu, 23 Jan 2020, 15:57 Tatiana Mesa, <tatianamesa687@gmail.com> wrote:Buenas tardes comunidad,--He empezado a trabajar con vistas basadas en clases en Django y tengo una pequeña complicación.Quisiera saber de que forma puedo separar un campo fecha (DateTimeField), en un input la feha y en otro input la hora en una vista de HTML.Tengo en mi modelo un campo de FechaY tengo un formulario para realizar updatesLes agradezco mucho sus respuestas.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHAr%3D_3CbZXT9x_NXQ-MJH8U3tJz7JEJj3-JxBuBx_s7JxUwqQ%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAO_yRT3twv2oPWkp_hRjsm4K433QFj_U6w%2B5-fqjytNBNOSdgw%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHAr%3D_2OBLQmNVD9pMaXtBor_1U7FZh8%3DgOXUenPLoCyxH1fuw%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAO_yRT2Q69rsFhLCBduVZkf%2BfMjmBXAGJG9Ju6NHGcjoLGxGfQ%40mail.gmail.com.


No comments:
Post a Comment