开发者

php/Symfony View Component analog in python/Django

Symfony has very useful feature - view component, this is small action code and template tha开发者_如何学Pythont you could embed anywhere inside view template:

<?php include_component('news') ?>

for example in above code mews component executes query in db and display results as block on a site page.

http://www.symfony-project.org/book/1_0/07-Inside-the-View-Layer#Components

I need something similar for Django to prepare and display login form in each view template.

We can call this a "widget" probably.


I think you're looking for Django's template tags feature. Template tags can make database calls, render partial templates, or do pretty much anything else you need them to do. Your example, as a template tag, might look something like this in your templates:

{% include_component 'news' %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜