Django: “TypeError: [] is not JSON serializable” Why?

Querysets are not serializable out-of-the-box. If you try list(self.items) instead of just self.items, that should work as long as the items themselves are JSON-serializable.

Update: It will raise an exception even if it isn’t empty. I don’t think it’ll be accepted as a Django bug, though of course you can try; the simplest answer is to force evaluation using list(qs), as I’ve already said.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)