mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Merge pull request #566 from mjtamlyn/patch-1
ObtainAuthToken pluggable Serializer.
This commit is contained in:
commit
431ced66e4
|
@ -12,10 +12,11 @@ class ObtainAuthToken(APIView):
|
|||
permission_classes = ()
|
||||
parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
|
||||
renderer_classes = (renderers.JSONRenderer,)
|
||||
serializer_class = AuthTokenSerializer
|
||||
model = Token
|
||||
|
||||
def post(self, request):
|
||||
serializer = AuthTokenSerializer(data=request.DATA)
|
||||
serializer = self.serializer_class(data=request.DATA)
|
||||
if serializer.is_valid():
|
||||
token, created = Token.objects.get_or_create(user=serializer.object['user'])
|
||||
return Response({'token': token.key})
|
||||
|
|
Loading…
Reference in New Issue
Block a user