diff --git a/static/css/styles.css b/static/css/styles.css index 870980072..99ce472a0 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -12,4 +12,4 @@ body { .click:hover { background-color: rgba(0, 0, 0, 0.05); cursor: pointer; -} \ No newline at end of file +} diff --git a/taxi/urls.py b/taxi/urls.py index 1399074dd..c2cc564d3 100644 --- a/taxi/urls.py +++ b/taxi/urls.py @@ -6,27 +6,27 @@ urlpatterns = [ path("", index, name="index"), path( - "manufacturers", + "manufacturers/", ManufacturerListView.as_view(), name="manufacturer-list" ), path( - "cars", + "cars/", CarListView.as_view(), name="car-list" ), path( - "cars/", + "cars//", CarDetailView.as_view(), name="car-detail" ), path( - "drivers", + "drivers/", DriverListView.as_view(), name="driver-list" ), path( - "drivers/", + "drivers//", DriverDetailView.as_view(), name="driver-detail" ), diff --git a/taxi/views.py b/taxi/views.py index 01b8a0154..e32084b4f 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -21,7 +21,7 @@ def index(request): class ManufacturerListView(generic.ListView): - # queryset = Manufacturer.objects.all().order_by("name") + # queryset = Manufacturer.objects.order_by("name") model = Manufacturer ordering = ["name"] context_object_name = "manufacturer_list" @@ -31,7 +31,7 @@ class ManufacturerListView(generic.ListView): class CarListView(generic.ListView): model = Car - queryset = Car.objects.all().select_related( + queryset = Car.objects.select_related( "manufacturer" ).prefetch_related("drivers") context_object_name = "car_list" @@ -58,6 +58,6 @@ class DriverDetailView(generic.DetailView): template_name = "taxi/driver_detail.html" def get_queryset(self): - return self.model.objects.prefetch_related("cars").filter( - id=self.kwargs.get("pk") - ) + return self.model.objects.prefetch_related( + "cars", "cars__manufacturer" + ).filter(id=self.kwargs.get("pk"))