Open Routhinator opened 5 years ago
From the traceback:
...
File "/usr/local/lib/python3.6/dist-packages/rest_framework/utils/encoders.py" in default
67. return tuple(item for item in obj)
File "/usr/local/lib/python3.6/dist-packages/rest_framework/utils/encoders.py" in <genexpr>
67. return tuple(item for item in obj)
File "/usr/local/lib/python3.6/dist-packages/django/core/files/base.py" in __iter__
78. for chunk in self.chunks():
...
Rest framework is trying to serialize the file by iterate trough it's content (bytes) which I'm not sure is what you want. Because you are using the djangorestframework can you show us also your serialyzer?
This is the serializer:
class MemberSerializer(ModelSerializer):
"""
Serializer for public Members endpoint
"""
groups = GroupSerializer(many=True, read_only=True)
class Meta:
model = Member
fields = (
'id',
'url',
'username',
'bio',
'language',
'homepage',
'location',
'avatar_url',
'avatar_100_url',
'avatar_50_url',
'groups',
'background_url'
)
It's a very vanilla DRF serializer. I ended up swapping imagekit out for django-versatileimagefield and everything works great with the same serializer in place, however I still have record of all the code that caused this in my git history so if any more information is required, I'll be happy to provide it.
Thank you for the information.
As I see you probably has few extra methods/properties in the model avatar_url
, avatar_100_url
, avatar_50_url
, which will probably are just basic getter for the url
property of the respecting field right?
This means that trying to create two thumbnails in the same request from the same source can fail.
Thank you again for reporting the issue.
Yes they return the url or a default noavatar image. They are marked with the @property
decorator.
same with s3 as media storage. And all works well if i remove content.seek(0)
app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/imagekit/cachefiles/__init__.py", line 103, in _generate app[web.1]: content.seek(0) app[web.1]: ValueError: I/O operation on closed file.
Any news on this? Getting same error on s3
Currently I have no time to look on this. If someone can debug it and came up with a patch I will be very greatfull.
Ok, after a thorough read of #391 I can say it's not related, though it is similar.
I am using Django default local storage. No storage plugins of any kind.
The following model code:
Causes the below error when attempting to retrive the model:
Versions (requirements.txt):
Traceback: