Reputation: 4343
In which cases is it better to create template tags (and load them into the template), than creating a context processor (which fills the request automatically)?
e.g. I have a dynamic menu that has to be included into all templates, so I'm putting it into my base.html. What is the preferred usage: context processor or custom template tag? And why?
Upvotes: 14
Views: 3070
Reputation: 391852
Context processors is for putting data (information, content, objects) into the context used to render page.
Template tags are for formatting or processing that content.
A template tag that makes up new data is confusing. Not impossible or wrong, but very confusing.
Upvotes: 19