PuercoPop
PuercoPop

Reputation: 6807

How do I load sorl's thumbnail template tag in all my templates

Given that sorl isn't an app directory wide and the template tag definition lives in the virtualenv dir

I want to be able to use {% thumbnail .... %} without having to use {% load thumbnail %} first. It can't be loaded in the layout apparently.

I know it is know critical but it would be nice %}

Upvotes: 0

Views: 438

Answers (2)

Bas Koopmans
Bas Koopmans

Reputation: 341

Copy paste the following code to an init.py that gets loaded,

from django import template
template.add_to_builtins('sorl.thumbnail.templatetags.thumbnail')

Upvotes: 2

hobbes3
hobbes3

Reputation: 30238

I don't think it's possible.

"When you load a custom tag or filter library, the tags/filters are only made available to the current template -- not any parent or child templates along the template-inheritance path."

So you'll have to declare {% load thumbnail %} in every template that uses the thumbnail tag.

Upvotes: 2

Related Questions