Templates(The Definitive Guild to Django)
2010-03-26 12:50
477 查看
Template:
<html>
<body>It is now {{ current_date }}.</body>
</html>
View:
def current_datetime(request):
now = datetime.datetime.now()
t = get_template('current_datetime.html')
html = t.render(Context({'current_date':now}))
return HttpResponse(html)
Settings:
settings.py TEMPLATE_DIRS = (
'/django/mysite/templates',
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
<html>
<body>It is now {{ current_date }}.</body>
</html>
View:
def current_datetime(request):
now = datetime.datetime.now()
t = get_template('current_datetime.html')
html = t.render(Context({'current_date':now}))
return HttpResponse(html)
Settings:
settings.py TEMPLATE_DIRS = (
'/django/mysite/templates',
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
相关文章推荐
- Advanced Templates(The Definitive Guild to Django)
- Generic Views(The Definitive Guild to Django)
- Generating Non-HTML Content(The Definitive Guild to Django)
- Advanced Models(The Definitive Guild to Django)
- Caching(The Definitive Guild to Django)
- Models(The Definitive Guild to Django)
- The Django Admin Site(The Definitive Guild to Django)
- Advanced Views and URLconfs(The Definitive Guild to Django)
- Views and URLconfs(The Definitive Guild to Django)
- Getting Started(The Definitive Guild to Django)
- Forms(The Definitive Guild to Django)
- Sessions, Users, and Registration(The Definitive Guild to Django)
- Introduction to Django(The Definitive Guild to Django)
- Deploying Django(The Definitive Guild to Django)
- The Definitive Guide To Django 2 学习笔记(四) 动态URLs
- The Definitive Guide to Installing Django on Ubuntu
- The Definitive Guide To Django 2 学习笔记(二) 第二个View 动态内容
- The Definitive Guide To Django 2 学习笔记(七) 第四章 模板 (三)使用模板系统
- The Definitive Guide To Django 2 学习笔记(八) 第四章 模板 (四)基本的模板标签和过滤器
- The Definitive Guide To Django 2 学习笔记(三) URLconfs 和松耦合