title: Query on a field value - returns Global name not defined
body: <p>Im tryin to write a query to filter/exclude some objects from a list, but I get a error.</p>
  
  <p>My models:</p>
  
  <pre><code>class Benefit(TimeStampedModel):
      DEAL = 'D'
      NODEAL = 'N'
  
      TYPE_CHOICES = (
          (NODEAL, 'Does not need any signed deal'),
          (DEAL, 'Needs a signed deal'),
      )
  
      name = models.CharField(max_length=200)
      benefit_type = models.CharField(max_length=1, choices=TYPE_CHOICES, default=DEAL)    
  
  
  
  class Profile(models.Model):
      user = models.OneToOneField(User)
      benefits = models.ManyToManyField(Benefit, verbose_name="Used benefits", blank=True, null=True, related_name="used_benefit")
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>class ProfilePage(TemplateView):
      template_name = "profile/frontpage.html"
  
      def get_context_data(self, **kwargs):
              context = super(ProfileFrontpage, self).get_context_data(**kwargs)
              context['unused_benefits'] = Benefit.objects.filter(used_benefit__isnull=True).exclude(benefit_type=='N')
              context['nodeal_benefits'] = Benefit.objects.filter(benefit_type=='N')
              return context
  </code></pre>
  
  <p>But it is not working. I get this error: <code>global name 'benefit_type' is not defined</code></p>
  
  <p>I not sure why I get that error? I did not think I needed to make a variable of a model field?</p>