Pillow corrupt image for serializer

2020-12-07 Thread cyril moreau
Hi Everybody, I try to use the serializer to save an image in my model as following: def save_file(file,owner): data ={} pic = None myfile = file is_image(myfile) data['image'] = file data['owner'] = owner s = ImageSerializer(data=data) if s.is_valid(): logg

Re: Pillow corrupt image for serializer

2020-12-07 Thread cyril moreau
I have found the solution (even if i dont understand why) it is not an issue due to pillow but the file itself. if my function is like is_image(myfile): myfile.read() I will have the same issue. The file pointer/cursor needs to be reseted to the first position with myfile.seek(0) it seems li

Re: Pillow corrupt image for serializer

2020-12-07 Thread Diyorbek Azimqulov
Hello sir. I started learning django. I want to be a backend web developer. It is good to see you On Mon, 7 Dec 2020, 18:49 cyril moreau, wrote: > I have found the solution (even if i dont understand why) > it is not an issue due to pillow but the file itself. > if my function is like > is_image

Documentation Swagger-UI how to add query parameters for GET methods

2020-12-07 Thread Mickael Lehoux Pro
Hello, i'm wasting many hours to understand how to generate good swagger-ui documentation with query parameters from function Based View in DRF 3.5. OpenApi Schema is done, Sqwagger-UI is done, Redoc too but get parameters aren't displayed from the ui. I don't undertsand how to edit schema o s

How should I avoid this race condition?

2020-12-07 Thread Gorgine Hoo
I have a piece of code like below which is truncated for concise: bargained_count = BargainLog.objects.filter(bargain_start_log=bargain_start_log).count() ... money = calc_single_bargain_money( bargained_count=bargained_count, .. ) ... BargainLog.objects.create(bargain_start_log=bargain_st

How should I avoid this race condition?

2020-12-07 Thread Gorgine Hoo
I have a piece of code like below which is truncated for concise: bargained_count = BargainLog.objects.filter(bargain_start_log=bargain_start_log).count() ... money = calc_single_bargain_money( bargained_count=bargained_count, .. ) ... BargainLog.objects.create(bargain_start_log=b