How does django return html directly without returning the html file?

if you want to return a small piece of html code directly in views instead of a html file, how to do it

Mar.18,2022

from django.http.response import HttpResponse

def res_func (req):

html_content= '<a href="https://github.com/Wenvki/django-idcops">idcops</a>'
return HttpResponse(html_content)

content-type is specified as text/plain

Menu