Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
serialize non django model
from rest_framework.views import APIView
from rest_framwrork import serializers
class NonDjangoModelSerializer(serializers.Serializer):
class Meta:
fields = ('field1', 'field1',)
field1 = serializers.Field()
field1 = serializers.Field()
class FooView(APIView):
serializer_class = NonDjangoModelSerializer
def get(self, request, *args, **kw):
...
my_data = argh_no_not_the_bees()
...
return Response(self.serializer_class(my_data).data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment