Created
March 2, 2015 21:26
-
-
Save psychok7/36d7e0b78abcb95a9741 to your computer and use it in GitHub Desktop.
Django Rest Framework + Django Hvad Usage Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MissionSerializer(TranslatableModelSerializer): | |
mission = serializers.CharField(source='mission') | |
class Meta: | |
model = Mission | |
class MissionViewSet(viewsets.ModelViewSet): | |
queryset = Mission.objects.language().all() | |
serializer_class = MissionSerializer | |
authentication_classes = (NoAuthentication,) | |
permission_classes = (AllowAny,) | |
def get_queryset(self): | |
user_language = self.request.GET.get('language') # Make sure you send ?language=en as a GET param | |
return Mission.objects.language(user_language).all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment