mirror of
https://github.com/django-components/django-components.git
synced 2025-10-04 11:14:39 +00:00
docs: document how to access component instance from within View (#1115)
This commit is contained in:
parent
5b01d6c3c6
commit
d37291a3b6
2 changed files with 36 additions and 0 deletions
|
@ -33,6 +33,18 @@ class ComponentView(ComponentExtension.ExtensionClass, View): # type: ignore
|
|||
# NOTE: This attribute must be declared on the class for `View.as_view()` to allow
|
||||
# us to pass `component` kwarg.
|
||||
component = cast("Component", None)
|
||||
"""
|
||||
The component instance.
|
||||
|
||||
This is a dummy instance created solely for the View methods.
|
||||
|
||||
It is the same as if you instantiated the component class directly:
|
||||
|
||||
```py
|
||||
component = Calendar()
|
||||
component.render_to_response(request=request)
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(self, component: "Component", **kwargs: Any) -> None:
|
||||
ComponentExtension.ExtensionClass.__init__(self, component)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue