python - is not JSON serializable -
i have following listview import json class countrylistview(listview): model = country def render_to_response(self, context, **response_kwargs): return json.dumps(self.get_queryset().values_list('code', flat=true)) but following error: [u'ae', u'ag', u'ai', u'al', u'am', u'ao', u'ar', u'at', u'au', u'aw', u'az', u'ba', u'bb', u'bd', u'be', u'bg', u'bh', u'bl', u'bm', u'bn', '...(remaining elements truncated)...'] not json serializable any ideas ? i'll add more detailed answer. it's worth noting queryset.values_list() method doesn't return list, object of type django.db.models.query.valueslistqueryset , in order maintain django's goal of lazy evaluation, i.e. db query required generate 'list' isn't performed until object evaluated. somew...