Skip to content

Commit

Permalink
fixed RecipeImageSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Jan 20, 2025
1 parent 1b17031 commit 7c93eed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cookbook/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,12 +965,12 @@ class RecipeImageSerializer(WritableNestedModelSerializer):
image_url = serializers.CharField(max_length=4096, required=False, allow_null=True)

def create(self, validated_data):
if not is_file_type_allowed(validated_data['image'].name, image_only=True):
if 'image' in validated_data and not is_file_type_allowed(validated_data['image'].name, image_only=True):
return None
return super().create( validated_data)

def update(self, instance, validated_data):
if not is_file_type_allowed(validated_data['image'].name, image_only=True):
if 'image' in validated_data and not is_file_type_allowed(validated_data['image'].name, image_only=True):
return None
return super().update(instance, validated_data)

Expand Down

0 comments on commit 7c93eed

Please sign in to comment.