Is it not possible to iterate over User objects using User.objects.all()?? I am trying to do the same but to no avail
I have a form;
class AddMemberForm(Form):
user = forms.ChoiceField(choices=User.objects.all(),
initial='Choose a User',
)
And I am trying to render it through a template. Corresponding part of views.py below;
class StationHome(View):
def get(self, request, pk):
station = Station.objects.get(pk=pk)
channels = Channel.objects.filter(station=station)
members = station.members.all()
form1 = AddMemberForm()
return render(request,
"home_station.html",
{"form1":form1,
"station":station,
"channels":channels,
"members":members,
},
)
Finally the corresponding part of the corresponding template,
<form method="post" action="{% url 'add_member' station.pk %}">
{% csrf_token %}
{{ form1 }}
</form>
But I am unable to access the URL due to this form. I get a TypeError at corresponding URL 'User' object is not iterable error.
Someone please help out.