middleware - Django-Components" > middleware - Django-Components" >
Skip to content

middleware ¤

Classes:

ComponentDependencyMiddleware ¤

ComponentDependencyMiddleware(get_response: Callable[[HttpRequest], HttpResponse])

Middleware that inserts CSS/JS dependencies for all rendered components at points marked with template tags.

Source code in src/django_components/dependencies.py
def __init__(self, get_response: "Callable[[HttpRequest], HttpResponse]") -> None:
    self.get_response = get_response

    # NOTE: Required to work with async
    if iscoroutinefunction(self.get_response):
        markcoroutinefunction(self)