牧羊人的冬天 2020-06-19 18:10 采纳率: 100%
浏览 488
已采纳

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条回答 默认 最新

  • threenewbee 2020-06-19 21:37
    关注
    检查报错的行
    str is not callable 一般发生在你搞错了变量的类型,或者调用属性加上了括号。
    比如
    class A:
      def __init__(seif):
        self.s = "aaa"
    
    a = A()
    print(a.s()) #错误,应该是 print(a.s)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#vscode#的问题:布料滤波算法中C++实现pcl在Vscode中pcl库没有#include <pcl>
  • ¥15 fpga:ov5640采集tft显示
  • ¥20 创建taro项目,在vscode上能够写跨平台写微信小程序代码
  • ¥15 网站出现错误跳转问题
  • ¥15 Docker容器里已经安装了ssh,但打包迁移到新机器一直容器一直提示unrecognized service。
  • ¥15 综合布线实例设计,就好看好看不恐怖可好滤镜好聚
  • ¥15 使用moviepy库视频合并时出错
  • ¥30 FLUENT液固传质UDF
  • ¥15 怎么看梯度直方图以,怎么判断梯度消失/爆炸,怎么解决
  • ¥15 aspnetdll文件访问拒绝