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
| Attribute | Type | Description |
|---|---|---|
| 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
| Name | Type | Description |
|---|---|---|
| context | object | The context object that manages the lifecycle and stack of this dictionary. |
| *args | tuple | Variable length argument list passed to the parent dict constructor. |
| **kwargs | dict | Arbitrary keyword arguments passed to the parent dict constructor. |
Signature
def ContextDict(
context: object,
*args: any,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| context | object | The context manager instance that tracks this dictionary as part of its state stack. |
| *args | any | Positional arguments passed to the underlying dict constructor for initial data population. |
| **kwargs | any | Keyword arguments passed to the underlying dict constructor for initial data population. |