I
I
Ilya Korol2019-07-27 00:45:36
Django
Ilya Korol, 2019-07-27 00:45:36

How to return a string with characters in Django without translation to character codes?

There are some API methods in Django.

{'response': {'user': {'nickname': 'welc32#1', 'id': 1, 'deleted': False, 'exp': {'scope': 0, 'level': 1, 'minLevelScope': 0, 'nextLevelScope': 10}, 'first_name': 'Илья', 'last_name': 'Канышев', 'online': 1564037487}, 'app_id': 1, 'access_token': 'ujCGpXPpxEmILwY1Biik'}}

{'response': {'user': {'nickname': 'welc32#1', 'id': 1, 'deleted': False, 'exp': {'scope': 0, 'level': 1, 'minLevelScope': 0, 'nextLevelScope': 10}, 'first_name': 'Илья', 'last_name': 'Канышев', 'online': 1564037487}, 'app_id': 1, 'access_token': 'ujCGpXPpxEmILwY1Biik'}}

From the first type you need to make the second. To make the translation from JSON to objects work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2019-07-27
@welcome32

https://docs.djangoproject.com/en/2.2/ref/request-...

>>> from django.http import JsonResponse
>>> response = JsonResponse({'foo': 'bar'})
>>> response.content
b'{"foo": "bar"}'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question