Django manage.py命令需要输入卡住

时间:2017-06-17 16:54:41

标签: django python-3.x

因为一段时间需要输入的任何python manage.py命令(删除null = True而不提供默认值,重新收集静态文件......)不接受所述输入。当我按下回车键时,它只是在控制台中显示回车符^M。我不知道如何调试这个,因为ctrl+ c只是给出了这样的追溯:

./manage.py makemigrations
You are trying to change the nullable field 'package' on company to non-nullable without a default; we cannot do that (the database needs something to populate existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
 2) Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)
 3) Quit, and let me add a default in models.py
Select an option: 1^M^M^M^C^CKeyboardInterrupt

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 177, in handle
    migration_name=self.migration_name,
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 47, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 189, in _detect_changes
    self.generate_altered_fields()
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 920, in generate_altered_fields
    new_default = self.questioner.ask_not_null_alteration(field_name, model_name)
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/questioner.py", line 182, in ask_not_null_alteration
    "Quit, and let me add a default in models.py",
  File "/Users/mac/.virtualenvs/mindance/lib/python3.6/site-packages/django/db/migrations/questioner.py", line 99, in _choice_input
    result = input("Select an option: ")
SystemError: <built-in function input> returned a result with an error set

有关如何处理此问题的任何提示?我重新安装了我的virtualenv。也许我应该重新安装python?

版本: Python 3.6.1 Django的== 1.11.2

1 个答案:

答案 0 :(得分:2)

首先在ubuntu终端中运行此命令stty sane,然后尝试使用python manage.py migrate

运行迁移