The 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte appears in the book system created based on the Django project

In the following situation, as shown in Fig.

Reason: hostname, aliases, ipaddrs = gethostbyaddr(name) -----hostname, aliases, ipaddrs=gethostbyaddr(name)
          UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte

           ------ (Unicode decode error): 'utf-8' codec can't decode byte 0xb3 in position 0: Invalid start byte

There are two solutions:

The first way is to find the system information in the computer and see if the name of your device is in Chinese. If not, it is the second solution. If it is, you can use this method or the second one.

Change the above device name to non-Chinese

 The computer needs to be restarted,

 Go start the project again, just fine

 The second one, you don’t need to restart the computer, just change it directly in the project, (recommended)

 Find the settings.py module in the project, add '*' in ALLOWED_HOSTS = [], as shown below

Then start the code command,

python manage.py runserver 127.0.0.2:8000

 The following picture will appear, and this problem will be solved

 After using these two methods, click the URL, and the page you want will appear, as shown in the figure below, (the following books are added by yourself)

 It is not scary to have a problem, but the problem is very simple and you are not willing to solve it. It is very important to have an attitude of pursuing the truth

Guess you like

Origin blog.csdn.net/bc_1024512/article/details/130050519