On Thu, 08 Jul 2010 18:07:58 +0200, Martin Tiršel <dja...@blackpage.eu> wrote:

Hello,

I am programming a small CMS on Django, I have editable pages, now I want to add news. I have a website where I want to display these news on every page in right/left column. I have following questions:

1.) Where is the right place to place news loader? TEMPLATE_CONTEXT_PROCESSORS seems to be a good place and easy to implement. Another possibility is a middleware, I feel, that it should go there instead of TEMPLATE_CONTEXT_PROCESSORS.

2.) If I use middleware, how do I smuggle variables into templates? It has something to do with the request object, but I don't know how to use it for that thing. What should I do in a middleware to have e.g {{ news }} template variable containing last x news?

Thanks for your advices,
Martin


I used template context processors to solve this problem, it is easier to implement now, but I will look at custom tags and cache, when I have some time :)

But can somebody answer my second question please? I need to know how can I transfer variables from middleware into templates.

Thanks,
Martin

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to