我正在从Python 2.7的Django 1.6.0迁移到Python 3.7的Django 2.1.5,并且在执行python manage.py makemigrations myapp
时遇到错误。有人能给我一个解决的提示吗?我可能需要修改模型,但不确定应该从什么开始。
Migrations for 'model':
model/migrations/0001_initial.py
- Create model XXXX
- Create model YYYY
- Create model ZZZZ
Traceback (most recent call last):
File "manage.py", line 7, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 184, in handle
self.write_migration_files(changes)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 222, in write_migration_files
migration_string = writer.as_string()
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/writer.py", line 151, in as_string
operation_string, operation_imports = OperationWriter(operation).serialize()
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/writer.py", line 110, in serialize
_write(arg_name, arg_value)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/writer.py", line 62, in _write
arg_string, arg_imports = MigrationWriter.serialize(item)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/writer.py", line 279, in serialize
return serializer_factory(value).serialize()
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/serializer.py", line 37, in serialize
item_string, item_imports = serializer_factory(item).serialize()
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/serializer.py", line 197, in serialize
return self.serialize_deconstructed(path, args, kwargs)
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/serializer.py", line 85, in serialize_deconstructed
arg_string, arg_imports = serializer_factory(arg).serialize()
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/serializer.py", line 37, in serialize
item_string, item_imports = serializer_factory(item).serialize()
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/serializer.py", line 37, in serialize
item_string, item_imports = serializer_factory(item).serialize()
File "/usr/local/lib/python3.7/site-packages/django/db/migrations/serializer.py", line 293, in serializer_factory
value = str(value)
File "/usr/local/lib/python3.7/site-packages/django/utils/functional.py", line 113, in __text_cast
return func(*self.__args, **self.__kw)
TypeError: gettext() takes 1 positional argument but 2 were given
如果需要,我将尝试提供有关该模型的更多详细信息。
答案 0 :(得分:-1)
在应用以下技术之前,请转储所有数据库。
删除所有迁移文件和文件夹,然后重新运行命令。
此外,比较Django文档中Django 1.6.0和2.1.5中使用的现有功能。