You misunderstood the answer from the first link, this answer suggests as a solution replacing the model in the Meta
class as in the code below. Also make sure you have set AUTH_USER_MODEL='custom_user_app.CustomUserModel'
in the settings file.
# You need to replace the direct import of your model with the one shown below
# from .models import User
from django.contrib.auth import get_user_model
User = get_user_model()
class RegisterSerializer(serializers.ModelSerializer):
password = serializers.CharField(
style={'input_type': 'password'},
write_only=True,
)
class Meta:
model = User
fields = ['email', 'password', 'password2']
...
Also try the same trick in your tests. This should fix your initial error, but there are still problems in your code, for example, the create
serializer method, replace the pasword
keyword with password
. I hope you are now clearer on what you should try to do, you should now check it yourself and let me know if your problem has been fixed?