Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 877 Bytes

headers.rst

File metadata and controls

27 lines (17 loc) · 877 Bytes

Headers

The headers sent by htmx are documented here.

The following code show how you access them in Django. This view behaves differently for htmx requests compared to normal requests:

def headers_demo(request):
    if request.headers.get("Hx-Request", False):
        current_url = request.headers["Hx-Current-URL"]
        return HttpResponse(f"This is a response to a request sent by htmx from {current_url}<br>")

    return TemplateResponse(request, "headers.html", {})

Example view code, template

Links