Return json data to the client under Django

Because there may be Chinese in the data, in order to avoid garbled characters, it is recommended to use HttpResponse

1. Use json.dumps to convert the data into json format, ensure_ascii=False

2. Add content type as:

content_type='application/json,charset=utf-8'

the following

ensure_ascii=False

and

content_type='application/json,charset=utf-8'

It can be guaranteed that even if the returned content contains Chinese, it can be displayed correctly.

Guess you like

Origin blog.csdn.net/x_xingduo_2315/article/details/123323795