template.Library.assignment_tag()

django.template.Library.assignment_tag() Deprecated since version 1.9: simple_tag can now store results in a template variable and should be used instead. To ease the creation of tags setting a variable in the context, Django provides a helper function, assignment_tag. This function works the same way as simple_tag() except that it stores the tag’s result in a specified context variable instead of directly outputting it. Our earlier current_time function could thus be written like this: @r

template.Engine.get_template()

Engine.get_template(template_name) [source] Loads a template with the given name, compiles it and returns a Template object.

template.context_processors.tz()

tz() [source] If this processor is enabled, every RequestContext will contain a variable TIME_ZONE, providing the name of the currently active time zone.

template.Engine.from_string()

Engine.from_string(template_code) [source] Compiles the given template code and returns a Template object.

template.context_processors.static()

static() [source] If this processor is enabled, every RequestContext will contain a variable STATIC_URL, providing the value of the STATIC_URL setting.

template.Engine

class Engine(dirs=None, app_dirs=False, context_processors=None, debug=False, loaders=None, string_if_invalid='', file_charset='utf-8', libraries=None, builtins=None, autoescape=True) [source] When instantiating an Engine all arguments must be passed as keyword arguments: dirs is a list of directories where the engine should look for template source files. It is used to configure filesystem.Loader. It defaults to an empty list. app_dirs only affects the default value of loaders. See below

template.defaultfilters.stringfilter()

django.template.defaultfilters.stringfilter() If you’re writing a template filter that only expects a string as the first argument, you should use the decorator stringfilter. This will convert an object to its string value before being passed to your function: from django import template from django.template.defaultfilters import stringfilter register = template.Library() @register.filter @stringfilter def lower(value): return value.lower() This way, you’ll be able to pass, say, an in

template.context_processors.debug()

debug() [source] If this processor is enabled, every RequestContext will contain these two variables – but only if your DEBUG setting is set to True and the request’s IP address (request.META['REMOTE_ADDR']) is in the INTERNAL_IPS setting: debug – True. You can use this in templates to test whether you’re in DEBUG mode. sql_queries – A list of {'sql': ..., 'time': ...} dictionaries, representing every SQL query that has happened so far during the request and how long it took. The list is i

template.Context.update()

Context.update(other_dict) [source] In addition to push() and pop(), the Context object also defines an update() method. This works like push() but takes a dictionary as an argument and pushes that dictionary onto the stack instead of an empty one. >>> c = Context() >>> c['foo'] = 'first level' >>> c.update({'foo': 'updated'}) {'foo': 'updated'} >>> c['foo'] 'updated' >>> c.pop() {'foo': 'updated'} >>> c['foo'] 'first level' Like push(),

template.Context.pop()

Context.pop()