[PYTHON] How to deal with garbled characters in json of Django REST Framework

One day suddenly json got garbled: joy:

Cause: Chrome update: joy: It is as follows.... 2017/04/11 http://var.blog.jp/archives/70125676.html

So, let's fix the REST Framework settings: muscle:

Currently, the characters are garbled

スクリーンショット 2017-04-16 午後3.12.29.png

: bulb: Remedy

Creating a ʻUTF8CharsetJSONRenderer class with ʻUTF-8 The REST Framework documentation says UTF-8 by default ... lol

renderers.py


from rest_framework.renderers import JSONRenderer

class UTF8CharsetJSONRenderer(JSONRenderer):
    charset = 'utf-8'
'DEFAULT_RENDERER_CLASSES': (
    #Comment out here!
    #'rest_framework.renderers.JSONRenderer',
    #Change to the one you made.(I'm in a directory called diary, so please change it to your own path.)
    'diary.renderers.UTF8CharsetJSONRenderer',
)

: cat: Kita! !! !! !! !! !!

スクリーンショット 2017-04-19 3.04.17.png

Recommended Posts

How to deal with garbled characters in json of Django REST Framework
How to write custom validations in the Django REST Framework
Implementation of custom user model authentication in Django REST Framework with djoser
How to deal with memory leaks in matplotlib.pyplot
How to implement "named_scope" of RubyOnRails with Django
How to create a Rest Api in Django
Implementing authentication in Django REST Framework with djoser
How to get people to try out django rest framework features in one file
How to automatically generate API document with Django REST framework & POST from document screen
How to deal with pyenv initialization failure in fish 3.1.0
When you want to filter with Django REST framework
How to eliminate garbled characters in matplotlib output image
How to deal with Executing transaction: failed in Anaconda
Implement hierarchical URLs with drf-nested-routers in Django REST framework
Django REST framework with Vue.js
Login with django rest framework
How to identify the element with the smallest number of characters in a Python list?
How to check ORM behavior in one file with django
[Django] How to give input values in advance with ModelForm
[AWS] How to deal with "Invalid codepoint" error in CloudSearch
For beginners, how to deal with common errors in keras
How to deal with imbalanced data
How to deal with imbalanced data
How to reflect CSS in Django
How to get started with Django
How to authenticate with Django Part 2
How to authenticate with Django Part 3
How to deal with python installation error in pyenv (BUILD FAILED)
How to deal with "You have multiple authentication backends configured ..." (Django)
Implementation of JWT authentication functionality in Django REST Framework using djoser
Implementation of CRUD using REST API with Python + Django Rest framework + igGrid
Create a REST API to operate dynamodb with the Django REST Framework
How to do arithmetic with Django template
Create RESTful APIs with Django Rest Framework
Logical deletion in Django, DRF (Django REST Framework)
Understand the benefits of the Django Rest Framework
How to check the version of Django
How to delete expired sessions in Django
CRUD POST with Nuxt & Django REST Framework
How to deal with enum compatibility errors
CRUD GET with Nuxt & Django REST Framework ①
How to do Server-Sent Events in Django
[Python] How to deal with module errors
How to convert DateTimeField format in Django
How to deal with SSL error when connecting to S3 with boto of Python
How to deal with old Python versions in Cloud9 made by others
CRUD PUT, DELETE with Nuxt & Django REST Framework
I want to create an API that returns a model with a recursive relationship in the Django REST Framework
How to deal with errors when hitting pip ②
[REAPER] How to play with Reascript in Python
How to keep track of work in Powershell
How to implement Rails helper-like functionality in Django
How to uniquely identify the source of access in the Django Generic Class View
How to create a JSON file in Python
can't pickle annoy. How to deal with Annoy objects
How to reflect ImageField in Django + Docker (pillow)
How to count the number of elements in Django and output to a template
How to run some script regularly in Django
Summary of how to use MNIST in Python
How to deal with module'tensorflow' has no attribute'〇〇'
How to deal with SessionNotCreatedException when using Selenium