Question

I'm trying to emulate this with djangos new class based generic views and can't figure it out:

urlpatterns = pattern('', 
(r'^about/(\w+)/$', about_pages),
)

def about_pages(request, page):
  return direct_to_template(request, template="about/%s.html" % page)

Is this just not possible with class based views? Do you have to overwrite as_view()? If so how do you do that?

Était-ce utile?

La solution

try this (not tested):

class AboutView(TemplateView):
    def get_template_names(self):
        return ["about/%s.html" % self.args[0]]

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top