Skip to content

Commit

Permalink
fixed validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pyprism committed Aug 17, 2024
1 parent 7748ef9 commit 2787e10
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions diary/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create(self, validated_data):

class DiarySerializer(serializers.ModelSerializer):
tags = TagSerializer(many=True, read_only=True)
tags_attach = serializers.ListField(child=serializers.CharField(), write_only=True)
tags_attach = serializers.ListField(child=serializers.CharField(), write_only=True, required=False)

def validate(self, data):
user = self.context['request'].user
Expand All @@ -51,7 +51,7 @@ def validate(self, data):
def create(self, validated_data):
user = self.context['request'].user
validated_data['user'] = user
tags_data = validated_data.pop('tags_attach', None, [])
tags_data = validated_data.pop('tags_attach', [])
diary = super().create(validated_data)

for tag_data in tags_data:
Expand Down

0 comments on commit 2787e10

Please sign in to comment.