程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python django

編輯:Python

Django There are many ways to transfer data from the background to the front .

 Templates
<html>
<head><title>Ordering notice</title></head>
<body>
<p>Dear {
{ person_name }},</p>
<p>Thanks for placing an order from {
{ company }}. It's scheduled to
ship on {
{ ship_date|date:"F j, Y" }}.</p>
<p>Here are the items you've ordered:</p>
<ul>
{% for item in item_list %}
<li>{
{ item }}</li>
{% endfor %}
</ul>
{% if ordered_warranty %}
<p>Your warranty information will be included in the packaging.</p>
{% endif %}
<p>Sincerely,<br />{
{ company }}</p>
</body>
</html>

stay Python Use template system in code , Please follow the steps below :
1, Create a with template code Template object
Django You can also specify the path of the template file Template object
2, Use some given variables context call Template Object's render() Method
This will return a fully rendered template , It's a string, All of these variables and block labels will be based on context Get the value


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved