<p>For my Django app I have Events, Ratings, and Users. Ratings are related to Events and Users through a foreign keys.  When displaying a list of Events I want to filter the ratings of the Event by a user_id so I know if an event has been rated by the user. </p>

<p>If I do:</p>

<pre><code>event_list = Event.objects.filter(rating__user=request.user.id)
</code></pre>

<p>(request.user.id gives the user_id of the current logged in user) ...then I only get the events that are rated by the user and not the entire list of events.</p>

<p>What I need can be generated through the custom SQL:</p>

<pre><code>SELECT *
FROM `events_event`
LEFT OUTER JOIN (
  SELECT *
  FROM `events_rating`
  WHERE user_id = ##
  ) AS temp 
ON events_event.id = temp.user_id
</code></pre>

<p>Is there an easier way so I don't have to use custom SQL?</p>

To make best use of Django, you have to avoid trying to do joins.
A "left outer join" is actually a list of objects with optional relationships.
It's simply a list of Events,
```
Event.objects.all()
```
.  Some Event objects have a rating, some don't.
You get the list of Events in your view.  You handle the optional relationships in your template.
```
```
{% for e in event_list %}
    {{ e }}
    {% if e.rating_set.all %}{{ e.rating_set }}{% endif %}
{% endfor %}
```
```
is a jumping-off point.