zoukankan      html  css  js  c++  java
  • django 标签

    django标签

    {% if/for/ifequal/ifnotequal condition %}

      ...{{ name|first|lower}}{# interpretation:lower the first word of name #}

    {% endif/endfor/endifequal/ifnotequal %}

    {% include %} 标签允许在"模板"中包含其它的模板的内容

     将工程里的settings.py的DIRS修改为:

    'DIRS': [os.path.join(BASE_DIR, 'templates')] ,

     以下内容在urls.py

    from django.conf.urls import url from . import view urlpatterns = [url(r'^$', view.django)]

     以下内容在view.html

    from django.http import HttpResponse from django.shortcuts import render

    def django(request):

        context = {}

        # context["question"] = u"aRe You OK?"

        # context["answer"] = u"i am fine,tks!"

        namelist = ["jackey","vickey"]

        context["namelist"] = namelist

        return render(request,'testdjango.html',context)

     以下内容在hello.html的<body></body>标签对里

     {% extends "base.html" %}
        {% block mainbody %}
    {#        <h1>{{ question|lower }}</h1>#}
    {#        <h1>{{ answer|upper|truncatechars:"10" }}</h1>#}
            {% for name in namelist %}
                <ul>
                {% if name == "jackey" %}
                    <li>{{ name }}</li>
                {% elif name == "vickey" %}
                    <li>{{ name }}</li>
                {% else %}
                    <li>{{ name }}</li>
                {% endif %}
                </ul>
            {% endfor %}
        {% endblock %}

  • 相关阅读:
    solr7之solrJ的使用
    solr7.3.1在CentOS7上的安装
    nginx配置:location配置方法及实例详解
    [读书]10g/11g编程艺术深入体现结构学习笔记(持续更新...)
    liunx系统计划任务管理(at/crond调度)
    Golden Gate 概念和机制
    Oracle三大经典表连接适用情况
    Oracle索引简单介绍与示例
    Oracle RAC的日志体系
    Oracle10g RAC的简单操作
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/6889777.html
Copyright © 2011-2022 走看看