4👍
✅
There’s no need to “intercept” anything. Rendered Django templates are simply strings, and there is a handy shortcut to do exactly what you want:
from django.template.loader import render_to_string
rendered = render_to_string('my_template.html', {'foo': 'bar'})
Source:stackexchange.com