GOOGLE ADS

Mittwoch, 27. April 2022

For-Schleife in Django-Ansichten

def lead_unassigned(request): unassigned = Agent.objects.all() for i in range(0,len(unassigned)): team_unassigned=profile_candidate.objects.exclude(Reference_Mobile = (unassigned[i]))

return render(request, 'leads/lead_list_unassigned.html', 
{'team_unassigned':team_unassigned})

I am a beginner
This is my views.py code,
profile_candidate is my mode, refrence_mobile one of the field
Agent is my another model which contains the list of agents,
here my task is to display the list of profile_candidates in which the refernce_mobile is not matching with any of the agents available in agent table
i tried with the above but it is checking only the last agent in the Agent model.
it is not checking all the users available in the agent model.
{% for i in team_unassigned %}
<tr>
<td>{{i.Name}}</td>
<td>{{i.DOB}}</td>
<td>{{i.highest_qualification}}</td>
<td>{{i.online_exam_status}}</td>
<td>
<a class="btn btn-sm btn-success" href="{% url 'lead_detail' i.pk %}">View</a>

<a class="btn btn-sm btn-success" href="{% url 'lead_update' i.pk %}">Update</a>
</td>

</tr>

{% endfor %}

</table>

this is my template displaying the list.
Can any one help me in achieving this,


Lösung des Problems

Jedes Mal, wenn die Schleife ausgeführt wird, erhält team_unassigned einen neuen Wert, wie von @dgw kommentiert. Sie können versuchen, die in -Methode wie folgt zu verwenden:

def lead_unassigned(request):
unassigned = Agent.objects.all()
team_unassigned=profile_candidate.objects.exclude(Reference_Mobile__in=(unassigned))
return render(request, 'leads/lead_list_unassigned.html',
{'team_unassigned':team_unassigned})

Keine Kommentare:

Kommentar veröffentlichen

Warum werden SCHED_FIFO-Threads derselben physischen CPU zugewiesen, obwohl CPUs im Leerlauf verfügbar sind?

Lösung des Problems Wenn ich das richtig verstehe, versuchen Sie, SCHED_FIFO mit aktiviertem Hyperthreading ("HT") zu verwenden, ...