This is my view.
def teacher_list(request):
group = Group.objects.get(name='Teacher')
users = group.user_set.all()
return render(request, "acnt/teacher-list.html", { "users": users })
This is the template I am using.
{% for teacher in users %}
<a href="#">{{ teacher.get_full_name }}</a> <br/>
{% endfor %}
{{ users }}
This is the result I am getting on my template.
John Doe
<QuerySet [<User: john>, <User: michel>]>
As you can see I have updated the group by adding another user michel
, and the users
object has both the users, but it is not showing in the loop I am using in the template. Why is this happening?
instead to see if gets id – Krishna Sunuwar Nov 27 '16 at 06:20