Ray's playground

 

Templates(The Definitive Guild to Django)

Template:

<html>
      
<body>It is now {{ current_date }}.</body>
</html>

 

 

View:

1 def current_datetime(request):
2     now = datetime.datetime.now()
3     t = get_template('current_datetime.html')
4     html = t.render(Context({'current_date':now}))
5     return HttpResponse(html)

 

 

Settings:

settings.py
1 TEMPLATE_DIRS = (
2     '/django/mysite/templates',
3     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
4     # Always use forward slashes, even on Windows.
5     # Don't forget to use absolute paths, not relative paths.
6 )

 

 

posted on 2010-03-26 12:50  Ray Z  阅读(143)  评论(0编辑  收藏  举报

导航