title: Distinc values of items coming from two querysets in Django view/template
body: <p>I need to output a list of works performed by a performer. The same work can have been performed multiple times, and in two different kind of event (e.g. <code>performanceOfWork</code> and <code>Event</code> models).</p>
  
  <pre><code>class Work(models.Model):
  
      title = models.CharField(max_length=200) # max_length = required
  
  class performanceOfWork(models.Model):
  
      solo_performer = models.ManyToManyField(Profile)
      performed = models.ForeignKey('Work', on_delete=models.CASCADE)
  
  class Event(models.Model):
  
      solo_performer = models.ManyToManyField(Profile)
      repertoire = models.ManyToManyField(Work, blank=True)
  </code></pre>
  
  <p>In the view I managed to get the distinct values from each of the two models:</p>
  
  <pre><code>context['repertoire_from_works'] = performanceOfWork.objects.filter(solo_performer=self.get_object().id).values('performed__title').distinct()
  context['repertoire_from_events'] = Event.objects.filter(solo_performer=self.get_object().id).values('repertoire__title').distinct()
  </code></pre>
  
  <p>But then, how do I deal with the same work being performed in both models? I just want to output it once. This is a very wonky attempt (which doesn't work because it checks both values within one nested loop):</p>
  
  <pre><code>      &lt;ul&gt;{% for work_works in repertoire_from_works.all %}
          {% for work_events in repertoire_from_events.all %}
            {% if work_works.performed__title == work_events.repertoire__title%}
              {% if forloop.first %}
              &lt;li&gt;{{ work_works.performed__title }}&lt;/li&gt;
              {% endif %}
  
            {% else %}
            &lt;li&gt;{{ work_events.repertoire__title }}&lt;/li&gt;
            &lt;li&gt;{{ work_works.performed__title }}&lt;/li&gt;
            {% endif %}
          {% endfor %}
        {% endfor %}
        &lt;/ul&gt;
  </code></pre>