You can use render_to_response
for returning multiple objects like that:
def get_queryset(self): # new
query = self.request.GET.get('q')
object_list = User.objects.filter(Q(username__icontains=query))
another_object_list = Doctor.objects.filter(Q(username__icontains=query))
context = {
'object_list': object_list,
'another_object_list': another_object_list
}
return render_to_response('search.html', context)
And you can call this context in your template:
{{ object_list }}
{{ another_object_list }}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…