blob: 4ace41b4346f0e4f50b7a871aba12ce2e5775bf2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
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 ["pages/%s.html" % obj.slug, 'pages/page.html']
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if self.request.user.is_anonymous:
context['login_form'] = AuthenticationForm()
return context
|