📜  使用 django 模型翻译和 django rest - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:10.267000             🧑  作者: Mango

代码示例1
As per documentation,

Using in combination with django-rest-framework
When creating a new viewset , make sure to override get_queryset method, using queryset as a property won’t work because it is being evaluated once, before any language was set.

****
So depending on your needs you can create a class inheriting from drf (for example ViewSet), obtaining the language code from request and replacing the get_queryset method to filter by language.