title: Using a string as the argument to a Django filter query
body: <p>I'm trying to do a django query, but with the possibility of several different <code>WHERE</code> parameters.  So I was thinking of doing something like:</p>
  
  <pre><code>querystring = "subcat__id__in=[1,3,5]"
  Listing.objects.filter(querystring)
  </code></pre>
  
  <p>Here Listing is defined in my model, and it contains the Many-To-Many field <code>subcat</code>.   However, that raises a <code>ValueError</code> because filter doesn't accept a string as its argument.  Is there a way in Python to have a string evaluated as just its contents rather than as a string?  Something like a print statement that prints the value of the string inline rather than to the standard output.</p>
  
  <p>By the way, the reason I don't just do </p>
  
  <pre><code>querystring = [1,3,5]
  Listing.objects.filter(subcat__id__in=querystring)
  </code></pre>
  
  <p>is that I'm not always filtering for <code>subcat__id</code>, sometimes it's one or several other parameters, and I'd rather not have to write out a bunch of separate queries controlled by if statements.  Any advice is much appreciated.</p>