Templates(The Definitive Guild to Django)

- 日理万妓 2021-11-10 00:06 321阅读 0赞

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:

ContractedBlock.gif ExpandedBlockStart.gif 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 )

转载于:https://www.cnblogs.com/zhtf2014/archive/2010/03/26/1696888.html

发表评论

表情:
评论列表 (有 0 条评论,321人围观)

还没有评论,来说两句吧...

相关阅读