I'm trying to set up a filter query in one of my views...basically my code looks as below:
def inventory(request):
vehicle = Vehicle.objects.all().exclude(status__status='Incoming').order_by('common_vehicle__series__model__manufacturer__manufacturer', 'common_vehicle__series__model__model', 'common_vehicle__year')
year_count = Vehicle.objects.exclude(status__status='Incoming').order_by('-common_vehicle__year__year').values('common_vehicle__year__year').annotate(count=Count('id'))
make_count = Vehicle.objects.exclude(status__status='Incoming').order_by('common_vehicle__series__model__manufacturer__manufacturer').values('common_vehicle__series__model__manufacturer__manufacturer').annotate(count=Count('id'))
return render_to_response('vehicles.html', {'vehicle': vehicle, 'make_count': make_count, 'year_count': year_count,})
def year_filter(request, year):
vehicle = Vehicle.objects.filter(common_vehicle__year__year=year)
return render_to_response('filter.html', {'vehicle':vehicle,})
def make_filter(request, make):
vehicle = Vehicle.objects.filter(common_vehicle__series__model__manufacturer__manufacturer=make).exclude(status__status='Incoming')
return render_to_response('filter.html', {'vehicle':vehicle,})
So far when I try any of the last two views, I'm only getting the query set from the first view i.e. inventory. The URLConf file looks as below:
(r'^inventory/year/(?P<year>d{4})/?$', 'app.vehicles.views.year_filter'),
(r'^inventory/make/(?P<make>)/', 'app.vehicles.views.make_filter'),