title: Django queryset not escaping text in a where...in query
body: <p>I'm trying to construct a fairly straightforward queryset that returns a list of values based on a set of criteria in a related table. Based on values from URL params, an array of values is passed to an <code>in</code> filter on the queryset. </p>
  
  <p>The problem is that Django passes those values as text <strong>without quotes</strong> into the SQL query and thus the query fails.</p>
  
  <p>The focal table contains information on companies ("Entity") and the related table information on offices ("Office") of those companies.</p>
  
  <p>This is the array of values being passed to queryset:</p>
  
  <pre><code>locations = [u'San Francisco', u'New York']
  </code></pre>
  
  <p>Here's the query:</p>
  
  <pre><code>companies = Entity.objects.values("name","summary").filter(office__city__in=locations)
  </code></pre>
  
  <p>Here's the query that actually hits SQL:</p>
  
  <pre><code>SELECT "entities_entity"."name", "entities_entity"."summary" FROM "entities_entity" INNER JOIN "entities_office" ON ("entities_entity"."id" = "entities_office"."entity_id") WHERE "entities_office"."city" IN (San Francisco, New York)
  </code></pre>
  
  <p>If I run the SQL query manually, but surround each of the statements in the <code>IN</code> clause with single quotes (not double quotes), it works fine.</p>
  
  <p>Any thoughts on why this is happening and how I can fix it?</p>
  
  <p>For what it's worth, here are the pertinent parts of the models</p>
  
  <pre><code>class Entity(models.Model):
      name = models.CharField(max_length=450)
      summary = models.TextField(blank=True,null=True)
  
  class Office(models.Model):
      entity = models.ForeignKey(Entity)
      city = models.CharField(max_length=250,blank=True,null=True)
  </code></pre>