title: AttributeError: 'Query' object has no attribute 'contains_aggregate'
body: <p>I'm making a Django app and I have a view that display both sides of an <code>object_set</code> (a reverse many to many). Because of this, I want to query all of the objects on both sides at the same time. Specifically speaking, I want to have all of the <code>Signup</code> objects that are associated with each <code>Event</code>.</p>
  
  <p>(The view page format should look like this.)</p>
  
  <pre><code>Event (0)
  -- Signup (0.0)
  -- Signup (0.1)
  -- Signup (0.2)
  -- Signup (0.3)
  Event (1)
  -- Signup (1.0)
  -- Signup (1.1)
  Event (3)
  -- Signup (3.0)
  -- Signup (3.1)
  -- Signup (3.2)
  -- Signup (3.3)
  ...
  </code></pre>
  
  <p>The code is as follows:</p>
  
  <pre><code>class TournamentDetailView(DetailView):
      model = Tournament
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          tournament_id = self.get_object().pk
          events = Event.objects.annotate(
              cached_signups=(
                  Signup.objects
                      .filter(event_id=OuterRef('pk'), tournament_id=tournament_id, dropped=False)
                      .order_by('created')
                      .defer('tournament')
              )
          ).all()
          context['events'] = events
          return context
  </code></pre>
  
  <p>Here's the traceback:</p>
  
  <pre><code>Traceback:    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py" in inner
    35.             response = get_response(request)    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
    128.                 response = self.process_exception_by_middleware(e, request)    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
    126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\views\generic\base.py" in view
    69.             return self.dispatch(request, *args, **kwargs)    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\views\generic\base.py" in dispatch
    89.         return handler(request, *args, **kwargs)    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\views\generic\detail.py" in get
    106.         context = self.get_context_data(object=self.object)    
  
  File "C:\Users\werdn\PycharmProjects\gwspo-signups-website\gwhs_speech_and_debate\tournament_signups\views.py" in get_context_data
    171.                     .defer('tournament')    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\manager.py" in manager_method
    82.                 return getattr(self.get_queryset(), name)(*args, **kwargs)    
  
  File "C:\Users\werdn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py" in annotate
    1000.             if alias in annotations and annotation.contains_aggregate:    
  
  Exception Type: AttributeError at /tournaments/detail/lobo-howl/
  Exception Value: 'Query' object has no attribute 'contains_aggregate'
  </code></pre>
  
  <p>I'm not sure why this is happening and it seems to be happening on the <code>Signups.objects</code> query but even with <code>Signups.objects.all()</code>, this Exception seems to be triggered. That leads me to believe that this is not an issue with the use of <code>OuterRef('pk')</code>.</p>