[Fixed]-How should template names be set dynamically using class based views?

35👍

You need to define get_template_names that returns list of template_names.

from django.views.generic import TemplateView

class DynamicTemplateView(TemplateView):

    def get_template_names(self):
        return ['%s.html' % self.kwargs['template']]

Leave a comment