Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

using django model translation with django rest


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.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #model #translation #django #rest
ADD COMMENT
Topic
Name
8+5 =