Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>EDIT after reading the other answers</h2> <p>The original answer I gave (here below unabridged) was correct in diagnosing what the problem is (<strong>the argument passed to the json function is not a list</strong>). I am leaving it as it explains the debugging procedure (maybe of some use for other similar situations), but the new answers of both @Jacinda and @Adam are more "to the point". In particular, the latter contains instructions on how to use a native django functionality to overcome the problem.</p> <h2>Original answer</h2> <p>Not 100% sure because I can't replicate the problem on my system, but from the look of it, it seems to me that it's a problem in the type/encoding of the data.</p> <p>I would start by testing again your code by manually assign <code>ids</code> with:</p> <pre><code>ids = [335L, 468L, 481L, 542L, 559L, 567L, 609L] </code></pre> <p>(on my system your code works in this case). If it works for you too, then investigate what kind of object is <code>ids</code> when assigned via <code>p.values_list('id',flat=True)</code> [you can do that with <code>type(ids)</code>]. It might be that <code>ids</code> is an object whose representation is the same as a list, but that it's not a list.</p> <p>In this case, you could try typecasting: <code>ids = list(p.values_list('id',flat=True))</code> before passing it to the json function but there is no guarantee that it will work (it depends if the returned value of <code>p.values_list</code> is iterable or not.</p> <p>HTH in at least tracking down the issue!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload