Skip to main content

ContextDict

This class provides a dictionary implementation that automatically registers itself with a parent context upon initialization. It functions as a context manager, ensuring that the dictionary is removed from the context's stack when the execution block exits.

Attributes

AttributeTypeDescription
context[BaseContext](basecontext.md?sid=django_template_context_basecontext)The parent context object that manages the stack of dictionaries for variable resolution.

Constructor

Signature

def ContextDict(
context: object,
*args: tuple,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
contextobjectThe context object that manages the lifecycle and stack of this dictionary.
*argstupleVariable length argument list passed to the parent dict constructor.
**kwargsdictArbitrary keyword arguments passed to the parent dict constructor.

Signature

def ContextDict(
context: object,
*args: any,
**kwargs: any
) - > null

Parameters

NameTypeDescription
contextobjectThe context manager instance that tracks this dictionary as part of its state stack.
*argsanyPositional arguments passed to the underlying dict constructor for initial data population.
**kwargsanyKeyword arguments passed to the underlying dict constructor for initial data population.