1👍
The !
at the start of the password value has a special meaning in Django – it means that an unusable password has been set for the user – the rest of the value is just a random string that will never be successfully validated.
So the question is why is an unusable password being set? There are two possibilities I can see from your code:
-
UserManager.create_super_user
doesn’t set the user’s password at all – if you are using this to create users, then no password will be set for them. -
If you’re using the
CreateUserSerializer
, then it may be that the value ofpassword
isNone
– we would need to see the serializer definition to confirm whether a null value would be considered valid. I think this is the most likely issue. PassingNone
tocreate_user
will causeset_password
to set an unusable password. You then need to investigate why an empty value is being passed to the serializer.
0👍
The problem was what solarissmoke proposed with the CreateUserSerializer. I had my password set to write only which wasn’t letting my view to get to password, instead it was returning None.
I changed my view from this:
class CreateUserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('email', 'password')
extra_kwargs = {
'password' : {'write_only': True}
}
To this (corrected version):
class CreateUserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('email', 'password')
- [Answered ]-Django fastest request between query and sub query
- [Answered ]-How to render specific template if two app have same template name?
- [Answered ]-Atomic transaction in django