2010-11-30 19 views
0

私は手動でレンダリングするテンプレートを持っていますが、フィルタを持つ日付はありません。文脈に入れる前に日付を書式設定せずにこれを行う方法はありますか?ここで手動で日付フィルタ付きのdjangoテンプレートをレンダリングする

コードです:

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 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. 

は日付が表示されないのはなぜ?

答えて

1

start_dateと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.' 
+0

ありがとう! – PhoebeB

関連する問題