title: Getting error when I try to convert raw queryset to queryset
body: <p>The query itself is correct and I am able to get the raw query set. I need to convert this into query set for further processing and I am facing below error.</p>
  <p>Creating corresponding django query was hard for me and that is why I created SQL query, got the raw query set and now attempting to convert it to query set for further processing.</p>
  <p>I have changed model and table names for anonymity.</p>
  <pre><code>queryset = Test1.objects.filter(id__in=RawSQL(&quot;SELECT DISTINCT ON (test1.start_time, test1.id) test1.id, test1.name, test1.start_time FROM test1 WHERE EXISTS (SELECT * FROM test2 JOIN test3 ON test2.test3_id = test3.id AND test3.value = '{param}' JOIN test4 ON test2.test4_id = test4.id AND test4.test1_id = test1.id) ORDER BY test1.start_time DESC&quot;.format(param=val)))
  Traceback (most recent call last):
    File &quot;&lt;console&gt;&quot;, line 1, in &lt;module&gt;
  TypeError: __init__() missing 1 required positional argument: 'params'
  </code></pre>
  <p>Here is the formatted raw query</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT
    DISTINCT ON (test1.start_time, test1.id) test1.id,
    test1.name,
    test1.start_time
  FROM
    test1
  WHERE
    EXISTS (
      SELECT
        *
      FROM
        test2
        JOIN test3 ON test2.test3_id = test3.id
        AND test3.value = '{param}'
        JOIN test4 ON test2.test4_id = test4.id
        AND test4.test1_id = test1.id
    )
  ORDER BY
    test1.start_time DESC.format(param = val)
  )
  </code></pre>