Example code for capturing current user from rest framework.

This commit is contained in:
Chris Church
2013-11-20 00:25:09 -05:00
parent e4851c6e18
commit b73e792b23
2 changed files with 12 additions and 0 deletions

View File

@@ -70,6 +70,15 @@ def get_view_description(cls, html=False):
class APIView(views.APIView):
def initialize_request(self, request, *args, **kwargs):
'''
Store the Django REST Framework Request object as an attribute on the
normal Django request.
'''
drf_request = super(APIView, self).initialize_request(request, *args, **kwargs)
request.drf_request = drf_request
return drf_request
def get_authenticate_header(self, request):
"""
Determine the WWW-Authenticate header to use for 401 responses. Try to