Django. How I can optimize db query?
<p>I have two models:  </p>

<pre><code>class Status(models.Model): 

     CHOISES = ( 
         ('new', 'New'), 
         ('in_progress', 'InProgress'), 
         ('on_review', 'OnReview'), 
         ('tested', 'Tested'), 
         ('delivered', 'Delivered') 
     ) 

    status_type = models.CharField( 
    max_length=11, 
    choices=CHOISES, 
    primary_key=True) 

class Task(models.Model):
    name = models.CharField(max_length=200, blank=False)
    status = models.ForeignKey(status)
</code></pre>

<p>part of my view:</p>

<pre><code>def task_list(request):

    all_tasks = Task.objects.all()
    tasks = {}

    tasks['new'] = all_tasks.filter(status_id='new')
    tasks['in_progress'] = all_tasks.filter(status_id='in_progress')
    tasks['on_review'] = all_tasks.filter(status_id='on_review')
    tasks['tested'] = all_tasks.filter(status_id='tested')
    tasks['delivered'] = all_tasks.filter(status_id='delivered')
....
</code></pre>

<p>part of my template:  </p>

<pre><code>{% for item in new %}
    &lt;div id="{{ item.pk }}"&gt;
        {{ item.name }}
    &lt;/div&gt;
{% endfor %}
&lt;/div&gt;
{% for item in in_progress %}
    &lt;div id="{{ item.pk }}"&gt;
        {{ item.name }}
    &lt;/div&gt;
{% endfor %}  
.....      
</code></pre>

<p>The question is, is there any way to optimize all my querysets, or it is imposible to select five filters for one db call?<br>
Like I understand, if I save in view only this call <code>all_tasks = Task.objects.all()</code> and then put logic in template, like this:   </p>

<pre><code>{% for item in all_task %}
{% if item.status_id == "new" %}
....
</code></pre>

<p>it will be exaclty five calls too<br>
Hope my question is not too broad</p>