Manually rendering django template with date filter

I've got the template to render manually, but not the dates with a filter. Is there a way of doing this without formatting the dates before I put them in the context?

Here is the code:

t= This is to notify you that you are booked on the course {{title}} that starts on {{start_date|date:"F j, Y"}} at {{start|time}} and is being held at {{venue}}.

c = {'startdate': datetime.datetime(2010, 12, 1, 9, 0), 'enddate': datetime.datetime(2010, 12, 1, 12, 0), 'has_cpd': False, 'title': 'Course 1', 'closes': None, 'creator': 1L, 'venue': 'Venue for Course 1', 'summary': 'Course 1 Summary', 'tags': '', 'attachment': <FieldFile: None>, 'organiser': 3L, 'id': 1L, 'opens': datetime.datetime(2010, 11, 30, 20, 1, 50, 951490), 'venue_map': None}

t.render(c)

This gives the output:

This is to notify you that you are booked on the course Course 1 that starts on  at  and is being held at Venue for Course 1.

Why don't the dates show up?

Answers


Looks like a simple typo between start_date vs. startdate.

In [18]: t= Template("""This is to notify you that you are booked on the course {{title}} that starts on {{startdate|date:"F j, Y"}} at {{start|time}} and is being held at {{venue}}.""")
In [19]: t.render(c)Out[19]: u'This is to notify you that you are booked on the course Course 1 that starts on December 1, 2010 at  and is being held at Venue for Course 1.'

Need Your Help

FFmpeg will not run from php

php windows iis-7 ffmpeg exec

This is a live server i am on a Windows 2008 Web Edition R2 server with IIS7.

Thunderbird centers some cells, but not others

html-email email-client thunderbird

Content in a responsive email template needs to appear centred in Thunderbird. The template involves a couple of tables nested inside a main table. Content centers in one of the tables, but not in ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.