title: Dynamic logic query builder in Django
body: <p>I'm have 2 table in DB:</p>
  
  <pre><code>class Param(models.Model):
      s_name = models.CharField(max_length=200)
      n_name = models.CharField(max_length=200)
  
  class ParamValue(models.Model):
      param = models.ForeignKey(Param)
      value = models.IntegerField()
      created = models.DateTimeField(default=datetime.now, blank=True)
  </code></pre>
  
  <p>I wanted to create dynamic constructor. Is there any library or method for create dynamic logic filter like as Apache Lucene or Solr?
  I mean something like this:</p>
  
  <pre><code>dyn_filter = parse("(value &lt; 200 AND value__s_name == 'pressure') 
      OR (value &gt; 10 AND value__s_name == 'depth')")
  result = ParamValue.objects.filter(dyn_filer)
  </code></pre>