python manage.py sqlmigrate xxx
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/core/management/commands/sqlmigrate.py", line 30, in execute
return super().execute(*args, **options)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/core/management/commands/sqlmigrate.py", line 64, in handle
sql_statements = executor.collect_sql(plan)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/db/migrations/executor.py", line 225, in collect_sql
state = migration.apply(state, schema_editor, collect_sql=True)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 112, in database_forwards
field,
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/db/backends/mysql/schema.py", line 44, in add_field
super().add_field(model, field)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 447, in add_field
self.execute(sql, params)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 132, in execute
self.collected_sql.append((sql % tuple(map(self.quote_value, params))) + ending)
File "/Users/youjunliang/workspace/hengshan/lib/python3.6/site-packages/django/db/backends/mysql/schema.py", line 33, in quote_value
quoted = quoted.decode()
AttributeError: 'str' object has no attribute 'decode'
解决方法:
decode()
修改为encode()
即可
网友评论