1π
β
{% for kurs in Kurs.objects.filter(prowadzacy__username=request.user.username) %}
<li>{{ kurs.nazwa }}</li>
{% endfor %}
This wonβt work in a template.
You will need to pass the filtered list to the template like so.
def userviewbasic(request):
kurs = Kurs.objects.filter(prowadzacy__username=request.user.username)
return render(request, 'polls/usersite.html', {"kurs": kurs})
And iterate over the parameter kurs
in the template.
{% for kur in kurs %}
<li>{{ kur.nazwa }}</li>
{% endfor %}
You can read more about the template language in Django here: https://docs.djangoproject.com/en/1.10/ref/templates/api/#rendering-a-context
π€Kedar
Source:stackexchange.com