Skip to content

Commit

Permalink
Fix: 유저 닉네임 업데이트 수정 (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
KangJeongHo1 authored Jun 17, 2024
1 parent c5f55d6 commit c1bbb32
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ class UserNicknameSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ['nickname']



def update(self, instance, validated_data):
instance.nickname = validated_data.get('nickname', instance.nickname)
instance.save()
return instance

def validate_nickname(self, value):
if User.objects.filter(nickname=value).exists():
raise serializers.ValidationError("이미 존재하는 닉네임입니다.")
Expand Down

0 comments on commit c1bbb32

Please sign in to comment.