Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.shortcuts import render
- from .models import Film, Series
- from .utils import ObjectDetailMixin
- from django.views.generic import View
- from django.views.generic import DetailView
- from django.http import HttpResponse
- # Create your views here:
- def index(request):
- films = Film.objects.all()
- series = Series.objects.all()
- return render(request, 'KinomonsterApp/base.html', context={'films': films, 'series': series})
- # class FilmDetail(ObjectDetailMixin, View):
- # def get(self, request, *args, **kwargs):
- # model = kwargs.get('pk')
- # template = 'KinomonsterApp/film_detail.html'
- # return render(request, 'KinomonsterApp/film_detail.html', context={'model': model})
- class FilmDetailView(DetailView):
- model = Film
- template_name = 'KinomonsterApp/film_detail.html'
- def get_context_data(self, **kwargs):
- # Call the base implementation first to get a context
- context = super().get_context_data(**kwargs)
- # Add in a QuerySet of all the books
- print(kwargs.get('pk'))
- # context['film'] = Film.objects.get(id=kwargs.get('pk'))
- return context
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement