ListAPIView in Django Rest Framework not return correct translation

17 views
Skip to first unread message

Alaydyn Gholechragh

unread,
Mar 7, 2020, 5:55:02 PM3/7/20
to Django users
hi
this my code :
class BookListAPIView(ListAPIView):
   queryset = Book.objects.all()
   serializer_class = Bookserializer

and django.po and compiled is :
msgid "title"
msgstr "عنوان"

#: .\app\models.py:13
msgid "price"
msgstr "قیمت"


and result is for http://127.0.0.1:8000/fa/ :

[
    {
        "id": 1,
        "title": "تست",
        "price": "900000"
    }
]

in result "title" and "price" not changed they should be  "عنوان" and "قیمت": 

i create a view for create new  object :

class BookCreateAPIView(CreateAPIView):
    queryset = Book.objects.all()
    serializer_class = BookCreateserializer

and translation for "title" and "price" worked correctly they are  "عنوان" and "قیمت": but i dont know why not work for ListAPIView  

Reply all
Reply to author
Forward
0 new messages