Answer by neferpitou for Why isn't my Django User Model's Password Hashed?
Here is an alternative to accepted answer.class CreateUserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('email', 'username', 'password') extra_kwargs = {'password':...
View ArticleAnswer by suhailvs for Why isn't my Django User Model's Password Hashed?
This worked for me.class UserSerializer(serializers.ModelSerializer): def create(self, *args, **kwargs): user = super().create(*args, **kwargs) p = user.password user.set_password(p) user.save() return...
View ArticleAnswer by spectras for Why isn't my Django User Model's Password Hashed?
The issue is DRF will simply set the field values onto the model. Therefore, the password is set on the password field, and saved in the database. But to properly set a password, you need to call the...
View ArticleAnswer by DRC for Why isn't my Django User Model's Password Hashed?
just override the create and update methods of the serializer: def create(self, validated_data): user = get_user_model(**validated_data) user.set_password(validated_data['password']) user.save() return...
View ArticleWhy isn't my Django User Model's Password Hashed?
I am using the Django REST Framework (DRF) to create an endpoint with which I can register new users. However, when I hit the creation endpoint with a POST, the new user is saved via a serializer, but...
View Article