python - In Django templates, `Context` is a stack. What for? -
django docs say context object stack:
from django.template import context c = context() c['a'] = 1 c.push() # make new context level c['a'] = 2 print(repr(c)) # [{'a': 1}, {'a': 2}] also docs say
using context stack comes in handy in custom template tags
however, there's no example that. suggestion: it's useful render subtemplate clean context ; 1 can use new empty context() object instead.
so, what's use case?
the use case scoping, example in loops , template inheritance.
Comments
Post a Comment