from django.views.generic.detail import DetailView from django.contrib.auth.forms import AuthenticationForm from pages.models import Page class PageDetailView(DetailView): model = Page slug_field = "slug" def get_template_names(self): obj = self.get_object() return ["%s.html" % obj.slug, "pages/%s.html" % obj.slug, 'pages/page.html'] class HomePageDetailView(PageDetailView): def get_object(self): return Page.objects.get(slug='homepage')