开发者

Django view/template boxes

I am new to python/django (came from PHP) and there is a design problem i have no idea how to solve.

Let's say we have main content block and some side column. Side column displayed at each page of website. But boxes can differ(same set, but in some pages particular boxes disabled) Side column has several boxes, like news, events, last anything, user details, statistics, etc. Dynamic data.

As well as i understand view function should fill context and invoke content.html (this renders main content block)

While context.html should extend base.html and that base.html has 开发者_如何转开发side column inside it.

The question is: How i pass all this data to side boxes(i am reminding, dynamic data connected to some models)? I hope someone can explain this to me. Thanks in advance


Hi and welcome to Django. The data in the context is available to all blocks. You don't have to do anything specific to pass context data to a block or an include.

Additionally, there are template tags that you can use to encapsulate other functionality that you might need at the template level: http://docs.djangoproject.com/en/1.3/howto/custom-template-tags/


After some additional research i found out, that there is 4 ways to do what i want

1) Middleware
2) Context proccessors
3) Inclusion tags(template tags), as Brendon mentioned.
4) django-blocks

I stopped on third approach. Tested first three.

Decided to start blog, to write down own notes...
More detailed review of this approaches:
http://tigra-potd.blogspot.com/2011/04/django-sidebar-boxesblocksmodules.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜