qq_39349120
牧羊人的冬天
采纳率100%
2020-06-19 18:10

python Django 迁移数据库数据错误TypeError: 'str' object is not callable

已采纳

python Django 迁移数据库数据错误TypeError: 'str' object is not callable

跪求大佬解救一下。。。

  1. mysql 创建数据库表正常:create database auto_ui DEFAULT CHARACTER set utf8;

  2. 进行数据迁移,Terminal中输入命令:
    python manage.py makemigrations
    python manage.py migrate
    输入报错:

    D:\wuyou_work\auto_ui>python manage.py migrate
    图片说明

    Traceback (most recent call last):
    File "manage.py", line 22, in
    execute_from_command_line(sys.argv)
    File "D:\python36\lib\site-packages\django\core\management__init__.py", line 364, in execute_from_command_line
    utility.execute()
    File "D:\python36\lib\site-packages\django\core\management__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "D:\python36\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, cmd_options)
    File "D:\python36\lib\site-packages\django\core\management\base.py", line 327, in execute
    self.check()
    File "D:\python36\lib\site-packages\django\core\management\base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
    File "D:\python36\lib\site-packages\django\core\management\commands\migrate.py", line 61, in _run_checks
    issues = run_checks(tags=[Tags.database])
    File "D:\python36\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
    File "D:\python36\lib\site-packages\django\core\checks\database.py", line 10, in check_database_backends
    issues.extend(conn.validation.check(
    kwargs))
    File "D:\python36\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
    issues.extend(self._check_sql_mode(**kwargs))
    File "D:\python36\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in check_sql_mode
    with self.connection.cursor() as cursor:
    File "D:\python36\lib\site-packages\django\db\backends\base\base.py", line 254, in cursor
    return self._cursor()
    File "D:\python36\lib\site-packages\django\db\backends\base\base.py", line 229, in _cursor
    self.ensure_connection()
    File "D:\python36\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
    File "D:\python36\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
    File "D:\python36\lib\site-packages\django\db\backends\mysql\base.py", line 274, in get_new_connection
    conn = Database.connect(**conn_params)
    File "D:\python36\lib\site-packages\pymysql\
    _init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
    File "D:\python36\lib\site-packages\pymysql\connections.py", line 706, in init
    self.connect()
    File "D:\python36\lib\site-packages\pymysql\connections.py", line 932, in connect
    self._request_authentication()
    File "D:\python36\lib\site-packages\pymysql\connections.py", line 1131, in _request_authentication
    authresp = _scramble(self.password('latin1'), self.salt)
    TypeError: 'str' object is not callable

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • caozhy 从今以后生命中的每一秒都属于我爱的人 10月前
    检查报错的行
    str is not callable 一般发生在你搞错了变量的类型,或者调用属性加上了括号。
    比如
    class A:
      def __init__(seif):
        self.s = "aaa"
    
    a = A()
    print(a.s()) #错误,应该是 print(a.s)
    
    点赞 评论 复制链接分享

相关推荐