views.py 350 B

12345678910111213
  1. from django.shortcuts import render
  2. from django.views.generic import TemplateView
  3. from .models import Car
  4. class CarView(TemplateView):
  5. template_name = 'django_drive_app/cars.html'
  6. def get_context_data(self, **kwargs):
  7. context = super().get_context_data(**kwargs)
  8. context['cars'] = Car.objects.all()
  9. return context