Skip to content

Instantly share code, notes, and snippets.

@ConorMcGee
Last active August 29, 2015 14:17
Show Gist options
  • Save ConorMcGee/a7a915792cff6fcb80e6 to your computer and use it in GitHub Desktop.
Save ConorMcGee/a7a915792cff6fcb80e6 to your computer and use it in GitHub Desktop.
Problem with Django rest swagger and get_serializer_class
def my_view_mocker(view):
view.request.tacos = 'Hi'
print "This is the viewmocker, just changed view.request.tacos to %s" % view.request.tacos
return view
class FileTree(generics.ListAPIView):
model = File
lookup_field = 'file_id'
paginate_by = 25
paginate_by_param = 'items'
def get_serializer_class(self):
print "This is the get_serializer_class method, self.request.tacos is %s" % self.request.tacos
return FileTreeSerializer
def queryset(self):
return File.objects.all()
def get(self, request, *args, **kwargs):
"""
---
view_mocker: my_view_mocker
"""
return super(FileTree, self).get(request, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment