执行python manage.py makemigrations出现如下错误解决方法

E:\django_demo\mysite01>python manage.py makemigrations app01
Traceback (most recent call last):
File “manage.py”, line 22, in
main()
File “manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “D:\python3.7\lib\site-packages\django\core\management_init_.py”, line 419, in execute_from_command_line
utility.execute()
File “D:\python3.7\lib\site-packages\django\core\management_init_.py”, line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “D:\python3.7\lib\site-packages\django\core\management\base.py”, line 354, in run_from_argv
self.execute(*args, **cmd_options)
File “D:\python3.7\lib\site-packages\django\core\management\base.py”, line 398, in execute
output = self.handle(*args, **options)
File “D:\python3.7\lib\site-packages\django\core\management\base.py”, line 89, in wrapped
res = handle_func(*args, **kwargs)
File “D:\python3.7\lib\site-packages\django\core\management\commands\makemigrations.py”, line 103, in handle
loader.check_consistent_history(connection)
File “D:\python3.7\lib\site-packages\django\db\migrations\loader.py”, line 294, in check_consistent_history
applied = recorder.applied_migrations()
File “D:\python3.7\lib\site-packages\django\db\migrations\recorder.py”, line 77, in applied_migrations
if self.has_table():
File “D:\python3.7\lib\site-packages\django\db\migrations\recorder.py”, line 55, in has_table
with self.connection.cursor() as cursor:
File “D:\python3.7\lib\site-packages\django\utils\asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “D:\python3.7\lib\site-packages\django\db\backends\base\base.py”, line 259, in cursor
return self._cursor()
File “D:\python3.7\lib\site-packages\django\db\backends\base\base.py”, line 235, in cursor
self.ensure_connection()
File “D:\python3.7\lib\site-packages\django\utils\asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “D:\python3.7\lib\site-packages\django\db\backends\base\base.py”, line 219, in ensure_connection
self.connect()
File “D:\python3.7\lib\site-packages\django\utils\asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “D:\python3.7\lib\site-packages\django\db\backends\base\base.py”, line 200, in connect
self.connection = self.get_new_connection(conn_params)
File “D:\python3.7\lib\site-packages\django\utils\asyncio.py”, line 33, in inner
return func(*args, **kwargs)
File “D:\python3.7\lib\site-packages\django\db\backends\mysql\base.py”, line 234, in get_new_connection
connection = Database.connect(**conn_params)
File "D:\python3.7\lib\site-packages\MySQLdb_init
.py", line 123, in Connect
return Connection(*args, **kwargs)
File “D:\python3.7\lib\site-packages\MySQLdb\connections.py”, line 185, in init
super().init(*args, **kwargs2)
TypeError: connect() argument 3 must be str, not int

注意:TypeError: connect() argument 3 must be str, not int
说明必须是字符串,就是setting.py文件中数据库必须为字符串

出现这个错误是因为’PASSWORD’: 123456, ‘POST’: 3306,设置成这样,应该设置成如下,解决!
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.mysql’,
‘NAME’: ‘test01’, # 数据库名
‘USER’: ‘root’,
‘PASSWORD’: ‘123456’,
‘HOST’: ‘localhost’,
‘POST’: ‘3306’,

}

}

你可能感兴趣的:(python,django,开发语言)