RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
djangourl和返回内容到html-创新互联

文章思维导图

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:申请域名网站空间、营销软件、网站建设、随县网站维护、网站推广。

django url和返回内容到html

nav.html, bottom.html, tongji.html

base.html




    {% block title %}默认标题{% endblock %} - lanny教堂


{% include 'nav.html' %}
//定义块,以后模版继承base后可以替换.
{% block content %}
这里是默认内容,所有继承自这个模板的,如果不覆盖就显示这里的默认内容。
{% endblock %}   {% include 'bottom.html' %} {% include 'tongji.html' %}

home.html继承且覆盖base

{% extends 'base.html' %}

{% block title %}欢迎光临首页{% endblock %}

{% block content %}
{% include 'ad.html' %}
这里是首页,欢迎光临
{% endblock %}

包含语法

{% include 'bottom.html' %}

{% block content %}
{% include 'ad.html' %}
{% endblock %}

字符串

views.py
def home(request):
    string = u"我在lanny教堂学习Django,用它来建网站"
    return render(request, 'home.html', {'string': string})
home.html
{{ string }}

列表:

views.py
def home(request):
    TutorialList = ["HTML", "CSS", "jQuery", "Python", "Django"]
    return render(request, 'home.html', {'TutorialList': TutorialList})
在视图中我们传递了一个List到模板 home.html:
教程列表:
{% for i in TutorialList %}
{{ i }}
{% endfor %}

home.html

教程列表:

{% for i in TutorialList %}
{{ i }}
{% endfor %}

字典

views.py

def home(request):
    info_dict = {'site': u'lanny教堂', 'content': u'各种IT技术教程'}
    return render(request, 'home.html', {'info_dict': info_dict})
home.html

法1:

站点:{{ info_dict.site }} 内容:{{ info_dict.content }}
法2:遍历
{% for key, value in info_dict.items %}
    {{ key }}: {{ value }}
{% endfor %}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站标题:djangourl和返回内容到html-创新互联
标题URL:http://scyingshan.cn/article/ddejgs.html