1、视图中使用模板

  模版的创建过程,对于模版,其实就是读取模版(其中嵌套着模版标签),然后将 Model 中获取的数据插入到模版中,最后将信息返回给用户

1.普通方法:HTML被直接硬编码在 Python 代码

def current_datetime(request):
    now = datetime.datetime.now()
    html = "<html><body>It is now %s.</body></html>" % now
    return HttpResponse(html)
View Code

相关文章:

  • 2022-12-23
  • 2021-11-11
  • 2022-02-15
  • 2021-06-11
  • 2021-07-18
  • 2021-05-26
猜你喜欢
  • 2021-08-07
  • 2021-09-06
  • 2021-07-07
  • 2022-12-23
  • 2021-12-05
  • 2021-10-12
  • 2022-12-23
相关资源
相似解决方案