title: problems with django raw query parameters
body: <p>I was trying to make a custom raw query for a model and i get this error:</p>
  
  <blockquote>
    <p>DatabaseError: error de sintaxis en o cerca de
    «E'positions_statusrecord'» LINE 1: SELECT id FROM
    E'positions_statusrecord' WHERE "type"=E'Leav...</p>
  </blockquote>
  
  <p>Here is the raw query i'm trying to use (it's a manager method):</p>
  
  <pre><code>def get_status_ids(self, model):
      """
      This query returns the latest statuses ids for each entry
      of "model" in StatusRecord.
      """
      db_table = self.model._meta.db_table
      model_type = model.get_status_type()
  
      raw_query = (
          "SELECT id "
          "FROM %s "
          "WHERE \"type\"=%s AND "
          "(identifier,date_time) IN "
                 "( "
                            "SELECT identifier, Max(date_time) "
                            "FROM %s "
                            "WHERE \"type\"=%s "
                            "GROUP BY identifier"
                 ")"
      )
  
      params = (db_table, model_type, db_table, model_type, )
      return self.raw(raw_query, params)
  </code></pre>
  
  <p>I've tried with a simpler query (just a <code>SELECT ... FROM ..</code>) and had the same problem. It seems to be that raw queries couldn't have the <code>FROM</code> part completed with a parameter.</p>
  
  <p>Am i right? or have i made a mistake and i'm not finding it?</p>
  
  <p>I'm using postgreSQL 8.4.10, django 1.3 and python 2.6.</p>
  
  <p>I've searched information about raw queries parameters to see if there are some forbidden formatting options, but i didn't find anything that helps me.</p>
  
  <p>Does anyone knows what's causing this error?</p>