Thursday, June 28, 2012

Re: have an object available in every templates

Well, I was curious to see if it worked with a context processor so I tried and indeed it works. After all it's only returning an object or list of objects in a dictionary. Now I don't know which method is the most efficient.

On Thursday, June 28, 2012 2:11:37 PM UTC+2, Bastian wrote:

I don't know if this is possible or how to do it. I would like to write a sort of context processor where I pass an object to the template. I have always passed strings to these variables. Let's say I have a Book model and in a view I list the latest books I've added to the database. In the corresponding template I will then have an objects list with these objects. But I also want to be able to call a variable containing another list of objects, say my favorite books, without having to pass it explicitly from the view and being able to call it from any template.
Can I do it with context processors, or anything else actually?


You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment