You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model called "Post" that looks for example like this:
# models.py
from django.db import models
from easy_thumbnails.fields import ThumbnailerImageField
class Post(models.Model):
name = models.CharField(max_length=255)
cover = ThumbnailerImageField(upload_to='posts')
Then I have a serializer for the model:
# serializers.py
class PostSerializer(serializers.ModelSerializer):
cover = ThumbnailSerializer(alias='small')
class Meta:
model = Post
fields = ['id', 'name', 'cover']
Finally I have a view:
# views.py
class PostView(generics.RetrieveAPIView):
queryset = Post.objects.filter(enabled=True)
serializer_class = PostSerializer
Now inside my test I try creating a post and fetching the data (im using PyTest):
I have a model called "Post" that looks for example like this:
Then I have a serializer for the model:
Finally I have a view:
Now inside my test I try creating a post and fetching the data (im using PyTest):
I also tried using:
cover=SimpleUploadedFile(name='test_image.jpg', content=open(image_path, 'rb').read(), content_type='image/jpeg')
But this ended up uploading the image to S3 which I dont want since its just a test and it should not upload anything to the cloud.
The text was updated successfully, but these errors were encountered: