diff --git a/backend/apps/pet/migrations/0004_alter_pet_pet_photo_url.py b/backend/apps/pet/migrations/0004_alter_pet_pet_photo_url.py new file mode 100644 index 0000000..d536d79 --- /dev/null +++ b/backend/apps/pet/migrations/0004_alter_pet_pet_photo_url.py @@ -0,0 +1,29 @@ +# Generated by Django 5.0.1 on 2024-02-19 06:15 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("pet", "0003_pet_pet_key_pet_slug"), + ] + + operations = [ + migrations.AlterField( + model_name="pet", + name="pet_photo_url", + field=models.FileField( + blank=True, + null=True, + upload_to="", + validators=[ + django.core.validators.FileExtensionValidator( + allowed_extensions=["png", "jpg", "jpeg"] + ) + ], + verbose_name="Pet photo", + ), + ), + ] diff --git a/backend/apps/pet/models.py b/backend/apps/pet/models.py index b8714f0..dc9ca1a 100644 --- a/backend/apps/pet/models.py +++ b/backend/apps/pet/models.py @@ -57,6 +57,7 @@ class Pet(TimeStampedModel): pet_photo_url = models.FileField( _("Pet photo"), blank=True, + null=True, validators=[FileExtensionValidator(allowed_extensions=["png", "jpg", "jpeg"])], ) location = models.CharField(_("Location"), max_length=50) diff --git a/backend/apps/pet/views.py b/backend/apps/pet/views.py index 38920f8..e5652be 100644 --- a/backend/apps/pet/views.py +++ b/backend/apps/pet/views.py @@ -131,7 +131,7 @@ def put(self, request, slug): serializer = self.serializer_class(pet, data=request.data) if serializer.is_valid(): pet = serializer.save() - return Response(self.serializer_class(pet).data) + return Response(self.serializer_class(pet).data, status=status.HTTP_200_OK) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) def delete(self, request, slug):