报错pymysql.err.DataError: (1406, "Data too long for column 'gender' at row 1")

When creating a superuser in Django's default admin background ,

  The solution to the error pymysql.err.DataError: (1406, "Data too long for column 'gender' at row 1") is reported.

The creation process is:

  Click run manage.py task in the tool menu, enter createsuperuser, run, and enter the user name, email, password, and password confirmation as prompted.

The solution is:

  Press the shortcut key ctr+h in pycharm to find the corresponding field of gender, as shown in the figure:

  

We can see that the gender character length is set to 5, but the female has 6 bytes, so modify max_length=10

Then run:

makemigrations users

run again:

migrate users

If there is a problem with these two commands, you can look here

 

Then we go through the above creation process again and it's OK.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324642810&siteId=291194637