Skip to content
Advertisement

Invalid password format or unknown hashing algorithm in Django class based view

I want to create user by API view. But I get this problem:

enter image description here

serializers.py

JavaScript

views.py

JavaScript

How can I solve this problem?

Advertisement

Answer

You should override serializer’s create() method to hash password before saving new user object. You can use set_password for this:

JavaScript

Otherwise User.password will be stared in DB without hashing which is not secure.

Also you can use create_user method which is calling set_password by defaut:

JavaScript
Advertisement