django-components/docs/templates/reference_signals.md
Juro Oravec 314ec77d3d
docs: Syntax highlighting for mkdocs (#984)
* feat:forward context processors variables in context in ISOLATED mode

	provide context_processors_data property to Component to access those variables in Component

* refactor: internalize RequestContext and pass HttpRequest internally

* docs: document HttpRequest and context processors

* docs: use djc_py code blocks for component definitions

---------

Co-authored-by: Lilian Durey <dureylilian@gmail.com>
2025-02-20 11:47:14 +01:00

883 B

Signals

Below are the signals that are sent by or during the use of django-components.

template_rendered

Django's template_rendered signal. This signal is sent when a template is rendered.

Django-components triggers this signal when a component is rendered. If there are nested components, the signal is triggered for each component.

Import from django as django.test.signals.template_rendered.

from django.test.signals import template_rendered

# Setup a callback function
def my_callback(sender, **kwargs):
    ...

template_rendered.connect(my_callback)

class MyTable(Component):
    template = """
    <table>
        <tr>
            <th>Header</th>
        </tr>
        <tr>
            <td>Cell</td>
        </tr>
    """

# This will trigger the signal
MyTable().render()