【发布时间】:2021-02-04 11:56:33
【问题描述】:
有没有办法让我将 PyCharm 配置为运行 shell_plus 而不是默认 shell?
我尝试将管理命令的文本放在“启动脚本”中,但随后我得到了以下内容 django_manage_shell.run("/Users/cmason/counsyl/code/website/counsyl/product") 导入操作系统 导入系统
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
# The new Django 1.4 default manage.py wants "from django..." before
# importing settings, but we usually tinker with sys.path in
# settings_local.py, which is called from settings.py. Importing
# settings.py works but does mean some double importing. Luckily that
# module does very little work.
import settings
# appease pyflakes; don't ever do this in
# non-super-meta-namespace-trickery code
settings
from django.core.management import execute_from_command_line
execute_from_command_line("shellplus")
它并没有真正运行 shell_plus。
似乎“启动脚本”是在默认值之外而不是在默认值之外发生的。
Shell_plus 自动导入所有 Django 模型类,等等。
【问题讨论】:
-
我可以通过使用
shell_plus作为自定义运行命令来让它工作。 -
这行得通,但它没有 PyCharm 命令行完成的优点,而且你不能使用命令行编辑(例如向上和向下箭头)。