title: In Django, how does one filter a QuerySet with dynamic field lookups?
body: <p>Given a class:</p>
  
  <pre><code>from django.db import models
  
  class Person(models.Model):
      name = models.CharField(max_length=20)
  </code></pre>
  
  <p>Is it possible, and if so how, to have a QuerySet that filters based on dynamic arguments?  For example:</p>
  
  <pre><code> # Instead of:
   Person.objects.filter(name__startswith='B')
   # ... and:
   Person.objects.filter(name__endswith='B')
  
   # ... is there some way, given:
   filter_by = '{0}__{1}'.format('name', 'startswith')
   filter_value = 'B'
  
   # ... that you can run the equivalent of this?
   Person.objects.filter(filter_by=filter_value)
   # ... which will throw an exception, since `filter_by` is not
   # an attribute of `Person`.
  </code></pre>