I tried to upload a JPEG image in the "Add logo" section and an internal error occurs on backside:
Internal Server Error: /api/v1/associations/media/
Traceback (most recent call last):
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\PIL\JpegImagePlugin.py", line 610, in _save
rawmode = RAWMODE[im.mode]
KeyError: 'P'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception
raise exc
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\mixins.py", line 19, in create
self.perform_create(serializer)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\associations\views\media.py", line 46, in perform_create
file=self.request.data["file"],
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\serializers.py", line 212, in save
self.instance = self.create(validated_data)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\rest_framework\serializers.py", line 948, in create
instance = ModelClass._default_manager.create(**validated_data)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\db\models\query.py", line 422, in create
obj.save(force_insert=True, using=self.db)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\db\models\base.py", line 744, in save
force_update=force_update, update_fields=update_fields)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\db\models\base.py", line 793, in save_base
update_fields=update_fields, raw=raw, using=using,
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\dispatch\dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\django\dispatch\dispatcher.py", line 175, in <listcomp>
for receiver in self._live_receivers(sender)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\associations\models\media.py", line 81, in create_preview
image.save(output, format=extension)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\PIL\Image.py", line 2164, in save
save_handler(self, fp, filename)
File "C:\Users\louis\Desktop\Portail-des-eleves\backend\venv\lib\site-packages\PIL\JpegImagePlugin.py", line 612, in _save
raise OSError(f"cannot write mode {im.mode} as JPEG") from e
OSError: cannot write mode P as JPEG
I tried to upload a JPEG image in the "Add logo" section and an internal error occurs on backside: