#error:underlying buffer has been detached
#Envirment: Docker, Django3.2.5, pyhton3.6
Scenario: the above error occurs every time I execute Python 3 manage.py runserver 0.0.0.0:8000
Finally, the problem was that I introduced the following code into some Python files
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach()) # System current default encoding format
However, this code is a habitual way of writing the default output code in Python 2.
Solution: delete all sys.stdout in the .Py file