python - Return django object in json and inject it to another json -


i search everywhere can't find answer. how can example return news posts in django in format like: {'status': 1, data: here_django_posts}. can use serialize how add json object? when put serialized data json.dumps data converted json again. wish in php:

$a = array(); $a['status'] = 1; $a['data'] = here_my_django_posts json_encode($a) 

ok i'm tired today. here working code:

products = serializers.serialize("json", products_model) return jsonresponse(1, products) def jsonresponse(status, data=none):     return httpresponse(json.dumps({'status': 1, 'data': json.loads(data)}), content_type="application/json") 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -