python - Simplejson django dict giving me an error -
i have next django dictionary --
titles_to_update = title.objects.exclude( error_message__startswith="no" ).filter( is_successful=false, updatebatch__is_completed=false ).values( 'id', 'apple_id', 'promotion_start_date', 'promotion_end_date', 'sd_price_tier', 'hd_price_tier' ) # {'hd_price_tier': 101, 'sd_price_tier': 2, 'apple_id': 270201401l, 'promotion_start_date': datetime.date(2014, 6, 27), 'id': 25332l, 'promotion_end_date': datetime.date(2014, 6, 30)}...] homecoming httpresponse(simplejson.dumps(titles_to_update))
this gives me error:
[my object] not json serializable
what need here encode dict in json?
here simple function wrote convert datetime objects work simplejson
:
def make_query_dict_jsonable(query_dict): list_of_objects = [] item in query_dict: info = {} field_name in title.keys(): data[field_name] = str(item[field_name]) list_of_objects.append(data) homecoming list_of_objects
python json django
No comments:
Post a Comment