Distinct values with Q objects
<p>I have this query on my Django project 1.10.1 on Py3:</p>

<pre><code>Event.objects.filter(Q(subject=topic.id) | Q(object=topic.id) | Q(place=topic.id))
</code></pre>

<p>How can I prevent to get two identical <code>Event</code> records? </p>

<p>Thank you in advance.</p>

<p>I don't think that query can ever give duplicate results.</p>

<p>I just tried a similar query on my similar setup, it will convert to an SQL query which looks roughly like this:</p>

<pre><code>SELECT * 
FROM event 
WHERE (subject=x OR object=x OR place=x)
</code></pre>

<p>This will not duplicate any rows, so you don't actually need to do anything to avoid duplicate records. </p>

python django