从下拉选择中传递过滤器后,我想转换为模型的 excel 内容。这是视图。
def ConvertToExcelView(request):
response = HttpResponse(content_type='text/csv')
writer = csv.writer(response)
writer.writerow([('name'), ('adm'),('form'),('stream') ])
for member in Marks.objects.filter(student__school__name=request.user.school).values_list('student__name', 'student__adm', 'student__klass__name', 'student__stream__name':
writer.writerow(member)
response['Content-Disposition'] = 'attachment; filename="members.csv"'
return response
有没有办法可以将其合并到视图中????
query = request.GET.get('view_classes')
if query:
queryset = (Q(student__klass__name__icontains = query))
return render(request,'students_marks.html',all_mark_results)
如果我对此不清楚,请要求更多说明。