3

I am using Jinja2 as my template system. I have created a jinja2.py file and set environment to use custom template filters, etc. But i don't know how to set custom_processor via jinja2?

def environment(**options):
    env = Environment(**options)

    env.filters['datetime'] = format_datetime

    env.globals.update({
        'static': staticfiles_storage.url,
        'url': reverse,
        'thumbnail': thumbnail,
        'customimagecrop':customimagecrop,

    })
    return env

Thanks

1 Answer 1

4

The Jinja2 backend does not support context processors. See this ticket (warning - it's a long read). You could try django-jinja, which does support context processors.

Sign up to request clarification or add additional context in comments.

7 Comments

Thank you i would use it for memcached but i have read that there is no need with jinja2. What do you think?
I'm not sure what you mean by using a context processor for memcached.
I was doing the caching ( via memcached ) inside a custom context_processor... ( workCategories = cache.get(cache_key_workcategories) )
I'm not sure why the choice of template language should affect whether or not you use caching.
I don't think that's relevant - those docs are about switching from Jinja1 to Jinja2, and it's talking about caching templates, not caching template variables.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.