Skip to content

Instantly share code, notes, and snippets.

@igr-santos
Created August 22, 2014 16:55
Show Gist options
  • Save igr-santos/a4eb354b859c21d10f1f to your computer and use it in GitHub Desktop.
Save igr-santos/a4eb354b859c21d10f1f to your computer and use it in GitHub Desktop.
example use Django Rest Framework
# serializers.py
class ObjectiveSerializer(serializers.ModelSerializer):
class Meta:
model = Objective
fields = (
'name', 'short_description', 'points_awarded',
'number_of_steps', 'energy_cost'
)
# views.py
class ObjectiveListAPI(generics.ListAPIView):
queryset = Objective.objects.all()
serializer_class = ObjectiveSerializer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment