title: Passing a Query Set to a Template
body: <p>I have a template that lists out all of the projects that have been created.  I've used the <code>models.Manager</code> to create a query set that counts the number of <code>tasks</code> a particular <code>project</code> has.  I've also created two variables in <code>views.py</code> that filter the results to provide more specific output.  Within my template I want to be able to display <code>Project X has 11 tasks open</code> and <code>Project Y has 5 tasks open</code> (in a tabular format).</p>
  
  <p>It should be noted that I can access the <code>TaskCount</code> manager's result by using <code>{{ project.tasks }}</code> but what I'm really interested in is accessing the <code>open_set</code> variable in my template.</p>
  
  <p><code>models.py</code></p>
  
  <pre><code>class TaskCount(models.Manager):
      def get_query_set(self):
          return super(TaskCount, self).get_query_set().annotate(tasks=Count('task'))
  
  class Project(models.Model):
      # Model Fields
      # some fields
      # Model Managers
      with_tasks = TaskCount()
  </code></pre>
  
  <p><code>views.py</code></p>
  
  <pre><code>class ListProject(ListView):
      model = Project
      template_name = 'list_project.html'
      # Queries
      open_set = Project.with_tasks.filter(task__status=0)
      closed_set = Project.with_tasks.filter(task__status=1)
  </code></pre>
  
  <p><code>list_project.html</code></p>
  
  <pre><code>{% for project in object_list %}
      &lt;tr&gt;
          &lt;!-- works --&gt;
          &lt;td&gt;&lt;a href="{{ project.get_absolute_url }}"&gt;{{ project.name }}&lt;/a&gt;&lt;/td&gt;
          &lt;!-- works --&gt;
          &lt;td&gt;{{ project.created_by }}&lt;/td&gt;
          &lt;!-- doesn't work --&gt;
          &lt;td&gt;{{ open_set }}&lt;/td&gt;
          &lt;!-- doesn't work --&gt;
          &lt;td&gt;{{ project.closed_set }}&lt;/td&gt;
      &lt;/tr&gt;
  {% endfor %}
  </code></pre>