title: Django query object filter
body: <p>I'm trying to get all objects from my DB that meet specified conditions. From my model <code>Training</code> I need to get all objects that are connected with logged user, date is in specified range and type of training is specified.
  Model:</p>
  
  <pre><code>class Training(models.Model):
      user = models.ForeignKey(User)
      date = models.DateField()
      length = models.TimeField()
      distance = models.FloatField()
      type = models.CharField(max_length=2,choices=TRAINING_TYPE)
      caloriesBurnt = models.FloatField()
      weight = models.FloatField()
      description = models.TextField(max_length=25)
  </code></pre>
  
  <p>View with filters:</p>
  
  <pre><code>def ReportRequest(request):
      if not request.user.is_authenticated():
          return HttpResponseRedirect('/login/')
      if request.method == 'POST':
          form = ReportForm(request.POST)
          if form.is_valid():
              usrname = request.user
              q = Training.objects.filter(user=usrname)
              q = Training.objects.filter(date__range=[form.cleaned_data['start'], form.cleaned_data['end']])
              q = Training.objects.filter(type=form.cleaned_data['type'])
              quantity = q.count
              if quantity == 0:
                  return HttpResponseRedirect('/notrainings/')
              avg_length = q.aggregate(Avg('length'))
              avg_distance = q.aggregate(Avg('distance'))
              avg_calories = q.aggregate(Avg('caloriesBurnt'))
              return HttpResponseRedirect('/report/')
          else:
              return render_to_response('reportform.html', {'form':form}, context_instance=RequestContext(request))
      else:
          form = ReportForm()
          return render_to_response('reportform.html',{'form':form}, context_instance = RequestContext(request))
  </code></pre>
  
  <p>And form in which user sets data range and type of training:</p>
  
  <pre><code>class ReportForm(forms.Form):
      start = forms.DateField(widget=SelectDateWidget(), initial=date.today())
      end = forms.DateField(widget=SelectDateWidget(),initial=date.today())
      type = forms.ChoiceField(required=True, choices=ACTIVITY_CHOICES, initial=RUNNING)
  </code></pre>
  
  <p>My problem: in my DB all trainings were made 9th and 10th December. When I set date range in my form from 2nd to 3rd Dec it should redirect me to <code>/notrainings/</code>. But it doesn't. No matter if I use <code>quantity = q.count</code> or <code>quantity = q.count()</code>. 
  I would greatly appreciate help with this topic.</p>
  
  <p><strong>Solved, thanks to both Mihai &amp; ruddra</strong></p>