On Thursday, June 28, 2012 5:53:46 PM UTC+2, Bastian wrote:
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.
The context_processor will be called for each and every RequestContext (so for each and every view AND templatetag creating a RequestContext), so better to avoid anything "intensive" here.
Also, it won't have access to the existing context - which may or not be a problem, but for something "my favorite books" (which really means : "the favorité books of request.user"), you can bet one day or another you will want to show "the favorite books of _another_ user", and this is something that won't work with a context processor.
To make a long story short : use a custom template tag that will take the user as an argument.
My 2 cents...