https://htmx.org logo
I learned about template context processors, and w...
# 🔥-django-htmx
h
I learned about template context processors, and wrote one which passes a
base_template
. Its value depends on whether or not the request was used with htmx or not, as per the tip on https://django-htmx.readthedocs.io/en/latest/tips.html.
Copy code
python
def htmx_base_template(request):
    if request.htmx and not request.htmx.boosted:
        base_template = "partial.html"
    else:
        base_template = "base.html"

    return {
        "base_template": base_template,
    }