9👍
I had the same problem recently… here’s my solution:
Confirm the encoding format of ‘file_path’:
- download and open the file with Notepad++
- check the lower right corner; there you can see whether your file was encoded in the compatible format, or if it has the Byte Order Marker or BOM sign,
- if either of these is true, simply ‘save as’ the correct/required format.
You should be fine with the above.
1👍
Just go on the location of file from Where the error is coming.
In my case the error was coming from json.py file in serializers, because my error is like:
File "C:\Users\User\AppData\Local\Programs\Python\Python38\Lib\site-packages\django\core\serializers\json.py",line 66 in Deserializer stream_or_string = stream_or_string.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
After going to location , just open json.py file with your idle or notepad, so that you can edit that file. Just go in Deserializer function on the line:
stream_or_string = stream_or_string.decode()
and change this line to
stream_or_string = stream_or_string.decode('UTF-16')
and save it,Now your error will be solved.
- [Django]-Can I do Django & Python web development using Xcode 3.2?
- [Django]-Django Rest framework authtoken 'module' object has no attribute 'views'
- [Django]-How to throw custom exception with custom error code on fly in django rest framework and override default fields in exception response
- [Django]-Django – Using context_processor
- [Django]-Use pyExcelerator to generate dynamic Excel file with Django. Ensure unique temporary filename
1👍
Partly with Abrahams solution above..
If your using VS Code, look in the lower right hand corner and it might say something like UTF-<xx>. Mine is in UTF-16. Simply click on it, then click ‘save with encoding’, and select ‘utf-8’. I keep forgetting that certain commands from the CLI, when creating files, will create them as UTF-8 (certain commands when running in powershell) $PSDefaultParametervalues['Out-File:Encoding'] = 'utf8'
- [Django]-Is apache necessary while we have python's built-in SimpleHttpServer
- [Django]-Exception Value: context must be a dict rather than WSGIRequest