diff --git a/rest_framework_jwt/serializers.py b/rest_framework_jwt/serializers.py index 12b10a44..9577c3b7 100644 --- a/rest_framework_jwt/serializers.py +++ b/rest_framework_jwt/serializers.py @@ -3,6 +3,7 @@ from calendar import timegm from datetime import datetime, timedelta +import django from django.contrib.auth import authenticate, get_user_model from django.utils.translation import ugettext as _ from rest_framework import serializers @@ -47,7 +48,10 @@ def validate(self, attrs): } if all(credentials.values()): - user = authenticate(**credentials) + if django.__version__ >= "1.11": + user = authenticate(request=self.context.get('request'), **credentials) + else: + user = authenticate(**credentials) if user: if not user.is_active: