Answer the question
In order to leave comments, you need to log in
Problem with django rest framework and knox?
I'm trying to write a rest-api for authentication through knox,
but when I try to post a request to
`auth/login/`issues
`TypeError at /authentication/login/
'str' object is not callable `
class LoginAPI(LoginView):
permission_classes = (permissions.AllowAny)
def post(self, request, format=None):
serializer = LoginSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user']
login(requests, user)
return super().post(request, format=None)
urlpatterns = [
path('login/', LoginAPI.as_view()),
path('validate_phone/', ValidatePhone.as_view()),
path('validate_otp/', ValidateOTP.as_view()),
path('register/', Register.as_view()),]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': {'knox.auth.TokenAuthentication', }
}
REST_KNOX = {
'USER_SERIALIZER': 'users.serializers.UserSerializer',
'TOKEN_TTL': timedelta(hours=24 * 7)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question