Skip to content

Commit

Permalink
Add id to user serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel-Luca committed Jun 5, 2024
1 parent 046aa75 commit fc85c1f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create(self, validated_data):
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = models.User
fields = ("username", "email")
fields = ("id", "username", "email")


class LoginSerializer(serializers.Serializer):
Expand Down
2 changes: 1 addition & 1 deletion backend/api/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def post(self, request):
serializer.is_valid(raise_exception=True)
user = serializer.validated_data["user"]
login(request, user)
return Response({"username": user.username}, status=status.HTTP_200_OK)
return Response(serializers.UserSerializer(user).data, status=status.HTTP_200_OK)


class LogoutView(views.APIView):
Expand Down

0 comments on commit fc85c1f

Please sign in to comment.