On Thu, 2006-06-15 at 00:19 -0700, Hugo Wetterberg wrote: > Hi All, > I was trying to output formatted dates in my template with > {{ entry.strftime("%A, %B %d") }} > > ...where entry is a datetime object. But I got an error where Django > said: > "Could not parse the remainder: ("%A, %B %d") > > Now I'm forced to send entry as a ready-formatted string from view, > which feels kind of wierd, and it's probably not the way to do it. > > What is the proper solution?
Use the "time" filter in templates. The formatting string you pass to the time filter is described in the documentation for the "now" template tag: http://www.djangoproject.com/documentation/templates/#now (the filter itself is documented lower down that page). In your case, {{ entry|time:"I, F j" }} will do what you want. Note that the format strings in templates are based on PHP's formatting strings, not the C and Python formatting strings. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---