Django - BaseSerializer.is_valid() takes 1 positional argument but 2 were given

This project was working before, but then Heroku took away free tier so I have been trying to deploy somewhere else, but now all of a sudden I cannot even create a user locally even though I could before... Now when I create a user I get the error mentioned in the title.

serializers folder file

from xml.dom import ValidationErr
from rest_framework import serializers
from django.contrib.auth import get_user_model, password_validation
from django.contrib.auth.hashers import make_password
User = get_user_model()

class UserSerializer(serializers.ModelSerializer):

  password = serializers.CharField(write_only=True)
  confirm_password = serializers.CharField(write_only=True)

  def validate(self, data):
    password = data.pop('password')
    confirm_password = data.pop('confirm_password')

    if password != confirm_password:
    raise ValidationErr({ 'confirm_password': 'Does not match the password'})


    data['password'] = make_password(password)

    return data
  class Meta:
    model = User
    fields = ('id', 'username', 'email', 'password', 'confirm_password') file

from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from rest_framework.exceptions import PermissionDenied
from django.contrib.auth import get_user_model
import jwt
User = get_user_model()
from datetime import datetime, timedelta
from jwt_auth.serializers.common import UserSerializer
from django.conf import settings

class RegisterView(APIView):

  def post (self, request):
    create_user = UserSerializer(
    return Response(, status=status.HTTP_201_CREATED)
    except Exception as e:
    return Response(e.__dict__ if e.__dict__ else str(e),        status=status.HTTP_422_UNPROCESSABLE_ENTITY)

class LoginView(APIView):
  def post(self, request):
    password ='password')
    username ='username')
    user_login = User.objects.get(username=username)
    except User.DoesNotExist:
    raise PermissionDenied('Credentials are incorrect!')
    if not user_login.check_password(password):
    raise PermissionDenied('Credentials are incorrect!')

    dt = + timedelta(days=7)

    token = jwt.encode(
    'exp': int(dt.strftime('%s'))
    print('TOKEN ----->', token)
    return Response({ 'token': token, 'message': f'Welcome back {user_login.username}' })

is_valid() only accepts keyword argument "raise_exception=True":

class RegisterView(APIView):

  def post (self, request):
    create_user = UserSerializer(

Change it into something like this:

def post(self, request):
    serializer = UserSerializer(
    if serializer.is_valid():
        user =
        return Response(, status=status.HTTP_201_CREATED)

    the rest of your code...
Back to Top