Python爬虫实战笔记_4 Final Homework

2016-07-24  本文已影响66人  Sugeei
模板继承
<div class="pusher">
    <div class="ui menu">
        <div class="header item" id="menu"> Menu
            <i class="content icon"></i>
        </div>
        <div class="item">About us
        </div>
        <div class="item">Location</div>
        <div class="item">Others</div>
    </div>
    {% block content %}
    {% endblock %}
{% extends 'nav.html' %}
{% block content %}
<div>
...
</div>
{% endblock %}
def contentview(request):
    ...
    return render(request, 'content.html', context)
url(r'^index/', contentview, name='stainfo')
完成效果
Screen Shot 2016-07-24 at 4.14.00 PM.png Screen Shot 2016-07-24 at 4.13.56 PM.png
为sidebar中的菜单项添加链接

Naming URL patterns
Name a URL and use it in template.
In urls.py

url(r'^statistic/', statisticdata, name='stainfo'),

In nav.html

{% url 'stainfo' %}

Done!

上一篇下一篇

猜你喜欢

热点阅读