Skip to content

Instantly share code, notes, and snippets.

@DoonDoony
Last active January 20, 2024 15:50
Show Gist options
  • Save DoonDoony/3fd7689bbbc40e3b779f36b765052f27 to your computer and use it in GitHub Desktop.
Save DoonDoony/3fd7689bbbc40e3b779f36b765052f27 to your computer and use it in GitHub Desktop.
Using `shell_plus` in pycharm django console
# 💡 NOTE: This only works if you are pretend to using `Django Console` feature in Pycharm
# Paste codes below into `Build, Execution, Deployment > Console > Django Console > Starting Script`
# requirements: `django_extensions`, `IPython`
import sys
import django
from IPython.core.getipython import get_ipython
from django_extensions.management.notebook_extension import load_ipython_extension
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()
ipython = get_ipython()
load_ipython_extension(ipython)
# NOTE: If you don't use the autoreload feature, don't paste the three lines below
load_ipython_extension(ipython)
ipython.extension_manager.load_extension('autoreload')
ipython.magics_manager.registry['AutoreloadMagics'].autoreload('2')
@WaYdotNET
Copy link

many thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment