I am not really understanding why I am unable to login as a user that I created using Django REST Framework. I am using the User Model from django.contrib.auth.models import User
.
I am spinning up the server locally, and can log in with a superuser that I created and access the data I want to, but I have created the API such that I can create Users through the browsable API, and I wish to log in with one of those users. However I am not able to.
Any suggestions? For the picture below, I would not be able to login using 'test' username, and 'test123' password.
This is the error when trying to log in. Please enter a correct username and password. Note that both fields may be case-sensitive.
SERIALIZER
class UserSerializer(serializers.HyperlinkedModelSerializer):
ideas = serializers.HyperlinkedRelatedField(many=True, view_name='idea-detail', read_only=True, allow_null=True)
ideacomments = serializers.HyperlinkedRelatedField(many=True, view_name='ideacomment-detail', read_only=True,
allow_null=True)
class Meta:
model = User
fields = ('url', 'id', 'username', 'password', 'email',
'first_name', 'last_name',
'date_joined', 'ideas', 'ideacomments')
VIEW
class UserViewSet(MultipleFieldLookupMixin, viewsets.ModelViewSet):
"""
This viewset automatically provides `list` and `detail` actions.
"""
queryset = User.objects.all()
The picture you posted shows a list of your users, right? I'm wondering why the password is shown in clear. Normally Django does not store passwords themselves but hashes. So maybe that's the problem? Did you use the User model's set_password function when creating the user?