Run shell_plus through PyCharm?

前端 未结 7 597
独厮守ぢ
独厮守ぢ 2020-12-28 17:11

Is there a way for me to configure PyCharm to run shell_plus instead of the default shell?

I\'ve tried putting the text of the manage command in the \'Starting scr

相关标签:
7条回答
  • 2020-12-28 18:05

    I've been looking for a solution to the same problem, and I ended up here. I tried solutions proposed by others, but none of those appeared to solve this issue. So I decided to find another solution. This is what I came up with:

    The code block below is the original Django Console starting script of PyCharm 2019.2:

    import sys, django
    print('Python %s on %s' % (sys.version, sys.platform))
    print('Django %s' % django.get_version())
    sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])
    if 'setup' in dir(django):
        django.setup()
    import django_manage_shell
    django_manage_shell.run(PROJECT_ROOT)
    

    Installing IPython and changing the last two lines as below gets it done in the most proper way:

    from IPython.core.getipython import get_ipython
    ipython = get_ipython()
    from django_extensions.management.notebook_extension import load_ipython_extension
    load_ipython_extension(ipython)
    

    To make it work: open PyCharm settings (CTRL+S) and head to Django Console section. Then make changes in Starting script window and apply. Finally, start the new Python Console instance.

    0 讨论(0)
提交回复
热议问题