推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
NeIO
V2EX  ›  Python

django 的模板重用问题

  •  
  •   NeIO · Apr 2, 2014 · 3224 views
    This topic created in 4596 days ago, the information mentioned may be changed or developed.
    最近接触了django, 用来做博客. 博客的每一篇文章用一个div容器包围,大致结构如下:
    <div>
    <!-- SOMETHING -->
    {% block content %}
    <!-- SOMETHING -->
    </div>
    现在问题是, 我想在一个页面上显示多篇文章, 而一个html文件却只能继承一次block content 的内容,也就是说, 只能显示一篇文章. .怎么解决呢 T T ,谢谢大家.
    ----------------------------
    2 replies  •  1970-01-01 08:00:00 +08:00
    gaicitadie
        1
    gaicitadie  
       Apr 2, 2014
    {% block content %}
    {% with 'myvar' as expectedVarName %}
    {{block.super}}
    {% endwith %}
    {% endblock content %}

    转自: http://stackoverflow.com/questions/1893579/django-passing-argument-to-parent-template
    xiaket
        2
    xiaket  
       Apr 2, 2014
    content作为一个列表传递进来, 模板里一个for来轮流取轮流渲染.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5559 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 02:41 · PVG 10:41 · LAX 18:41 · JFK 21:41
    ♥ Do have faith in what you're doing.