I am passing in a bunch of Project objects into my template as the variable 'projects'. Then I loop over each of them like this:
{% for project in projects %}
<div class="conflict">
<h2>{{ project.title }}</h2>
<div class="conflictdata">
<p>A conflict with *USER*</p>
<p>Created on *DATE*</p>
<p>MORE INFO HERE?</p>
</div>
</div>
{% endfor %}
Now the project models has a many to many relationship with the Django user model (but each project only has two users) (while every user can have many projects). What I would like to do is exclude the current logged in {{user}} from the Project.users queryset and display it in my template (because that would be the user with whom the current logged in user shares said project).
How could I achieve this?
Also here's my view in case it helps:
@login_required
def myconflicts(request):
form = ProjectForm(request.POST or None)
if request.method == "POST":
form = ProjectForm(request.POST)
if form.is_valid():
project = form.save()
project.users.add(request.user)
project.users.add(User.objects.last())
return redirect('problemdashboard:problem-dashboard', project_id=project.pk)
form = NeedForm()
else:
form = NeedForm()
return render(request, 'conflictmanagement/myconflicts.html', {
'form': form,
'projects': request.user.project_set.all()
})