Using a string as template in CBV

Hey @valentinogagliardi — as I said on Twitter, you’re nearly there, but you’re probably importing the wrong class.

Compare django.template.backends.django.Template, which takes the request TemplateResponse is trying to pass to it with django.template.base.Template, which doesn’t.

You’re not really ever meant to use base.Template. (Why’s it there? History…) As per the Loading a template docs

The recommended way to create a Template is by calling the factory methods of the Engine : get_template() , select_template() and from_string() .

You want from_string():

>>> from django.template import engines
>>> django_engine = engines['django']
>>> template = django_engine.from_string("Hello {{ name }}!")
>>> template.render({"name":"Valentino"}, request=None)
'Hello Valentino!'

All those examples not using the backend API need to disappear, but likely never can.
HTH