I am using django-filters in my project. Let's say I get this address after a search:
?title=my title&ms=8
As you can see, I've searched for 'my title' and for a manuscript which the user sees as 'my manuscript', but whose get
parameter (and ID) is 8.
Now, I'd like to add to my template a courtesy 'you've searched for' field. How can I show the title of that manuscript, rather than its ID?
I already have the ms objects in my view:
mstunes = MsTune.objects.all()
ms = Manuscript.objects.all() <- manuscripts
f = MsTuneFilter(request.GET, queryset=MsTune.objects.all())
return render(request, 'manuscript/mstune_list.html', {'mstunes': mstunes, 'f': f, 'request':request, 'ms': ms})
and I can indeed access them with {{ms.all}}
. Is it possible to do something, in pseudo code, like:
show the ms.title of the ms object with id = request.GET.ms
?
My view:
def MsTuneList(request):
mstunes = MsTune.objects.all()
ms = Manuscript.objects.all() # can I get the ms.id from the request, with, say, request.ms, and then use it with get(id=ms)?
f = MsTuneFilter(request.GET, queryset=MsTune.objects.all())
return render(request, 'manuscript/mstune_list.html', {'mstunes': mstunes, 'f': f, 'request':request, 'ms': ms})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…