2010-11-30 9 views
0

Ich habe die Vorlage, um manuell zu rendern, aber nicht die Daten mit einem Filter. Gibt es eine Möglichkeit, dies zu tun, ohne die Daten zu formatieren, bevor ich sie in den Kontext stelle? HierManuelles Rendern von Django-Vorlage mit Datumsfilter

ist der 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) 

Dadurch wird die Ausgabe gibt:

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. 

Warum nicht die Daten angezeigt?

Antwort

1

Sieht aus wie ein einfacher Tippfehler zwischen Startdatum und Startdatum.

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

Oops - danke! – PhoebeB

Verwandte Themen