我正在尝试将从提交的表单(POST)收到的一些参数传递给ListView,以便我可以根据这些参数生成相关的查询集。
我不清楚除View之外是否应在URL中指定参数?
从当前视图:
area = form.cleaned_data['area']
service = form.cleaned_data['service']
usage = form.cleaned_data['usage']
return redirect('users:results', area=area, service=service, usage=usage)
urls.py
url(r'^results/$', views.ResultsView.as_view(), {}, name="results", ),
views.py
class ResultsView(ListView):
template_name = 'site/results.html'
paginate_by = 20
context_object_name = 'results'
def get_queryset(self, area, service, usage):
results = Results.objects.filter(area=area, service=service, usage=usage)
return results