https://htmx.org logo
Again, drf already handles it! When you pass `temp...
# 🔥-django-htmx
w
Again, drf already handles it! When you pass
template_name
as a kwarg to the
Response
constructor, drf passes
data
(first argument to the constructor) as context to the template behind the scenes if the request if for the content type of
text/html
So:
Copy code
python
@api_view
def foo_view(request):
  return Response({'message': 'hello!'}, template_name="foo.html")
Copy code
html
<h1>{{ messgae }}</h1>