[Answer]-Django: Tastypie filesize

1👍

You should use dehydrate method and make something like this:

class MyResource(ModelResource):
    photo = fields.FileField(attribute="photo")
    class Meta:
        queryset = Note.objects.all()

    def dehydrate(self, bundle):
        bundle.data['photo_size_in_bytes'] = bundle.obj.photo.size  # size in bytes 
        return bundle

This will add size in bytes to your json.

Leave a comment