viestards escribió: >> Using the 'date' filter, you can format the output however you want, >> within templates. >> >> For example, to format a date as "September 17, 2006", you would do >> the following in a template: >> >> {{ object.pub_date|date:"F d, Y" }} > > thanks for reply, but will it work on forms?
I use a small dirty trick. It's dirty, but I feel it's easier and quicker than building custom validators/manipulators. I have a small function: ---------------------------------------------- def cadena_a_fecha(strfecha): # Eliminamos todos los posibles separadores strfecha=strfecha.replace("-","") strfecha=strfecha.replace("/","") strfecha=strfecha.replace(" ","") strfecha=strfecha.replace(".","") # Probamos varios metodos try: fecha=time.strptime(strfecha,"%d%m%y") except ValueError : fecha=time.strptime(strfecha,"%d%m%Y") return datetime.date(fecha[0],fecha[1],fecha[2]) ------------------------------------------ It takes a string, removes the usual data separators and try to convert it to a datetime using the python strptime. In the form view code I did something like that -------------------------------- def formulario(request,visita_id): <split> if request.POST : datos = request.POST.copy() errores = manipulador.get_validation_errors(datos) if errores.has_key('Fecha') : # Error de fecha, vamos a intentar convertirla try: fecha = cadena_a_fecha(datos['Fecha']) except : pass else : datos['Fecha']=fecha.strftime("%Y-%m-%d") errores=manipulador.get_validation_errors(datos) <split> ------------------------------- I use the usual form stuff. But if I detect an error on the date field (Fecha in Spanish) I just throw the string to the previous function. If it doesn't raise an exception I use the return to build a sting that django will accept and call get_validation_errors again. It's not pretty, not very portable, prone to break when the main manipulator code/system change, but... well it's easy. Javier. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---