3

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?

ekad
  • 14,436
  • 26
  • 44
  • 46
MiniGunnR
  • 5,590
  • 8
  • 42
  • 66

0 Answers0