views.py
def appelli(request, corso_id):
corsi = Corso.objects.filter( pk=corso_id)
fasca = Corso.objects.get( pk=corso_id)
appello=[
list(Iscrizione.objects.filter(corso1_id=fasca)),
...]
return render(request, 'corsi/appello.html', {'appello':appello})
in the html use {{appello.0}}
and I render this:
[<Iscrizione: VFEW>, <Iscrizione: VFFF>]
how can delete "Iscrizioni" and make a ordinate list?
def appelli(request, corso_id):
...
fasca = Corso.objects.get( pk=corso_id)
appello= Iscrizione.objects.filter(corso1_id=fasca)
context={
'appello':list(appello),
}
return render(request, 'corsi/appello.html', context)
in the template you can use appello as an ordinary list.
Iscrizione.objects.filter(corso1_id=fasca).values_list('fieldname', flat=True)
https://docs.djangoproject.com/zh-CN/2.0/ref/models/querysets/#values-list
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.