问题
I wrote the django blog and api.
When i started the postman and then wrote the api url it returns correct values except content i have issue with content content is returning ö . It's turkish charset ö=ö How can i fix this problem ?
api/serializers.py:
class MakaleSerializer(serializers.ModelSerializer):
Yazar = serializers.CharField(source="Yazar.username")
class Meta:
model = Makale
fields = ('__all__')
def to_representation(self, instance):
data = super().to_representation(instance)
data['İçerik'] = strip_tags(instance.İçerik)
return data
api/views.py:
class MakaleRudView(APIView):
def get(self, request):
makale = Makale.objects.all()
serializer = MakaleSerializer(makale , many=True)
return Response(serializer.data)
and the postman or drf(Django Rest Framework returns :
{
"id": 26,
"Yazar": "gorkem",
"Başlık": "Atatürk'ün Samsuna Çıkışı 2",
"İçerik": "Atatürk'ün Samsuna çıkışı sırasında Türkiye Cumhuriyeti'nin",
"Olusturma_Tarihi": "2020-05-29T09:10:43.874477+03:00",
"makal_resim": null
},
来源:https://stackoverflow.com/questions/62081405/django-rest-framework-doesnt-escape-html-entity-problem