Skip to content

Instantly share code, notes, and snippets.

@anuragregmi
Last active January 22, 2020 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anuragregmi/5618329e256cd7c0a28c6412fe966232 to your computer and use it in GitHub Desktop.
Save anuragregmi/5618329e256cd7c0a28c6412fe966232 to your computer and use it in GitHub Desktop.
Running shell plus in python console pycharm
  1. Open settings of pycharm (Ctrl+Alt+S)

  2. Go to django console settings (Simply search "django console")

  3. In starting script replace with following

    Note: If you have different settings module, then set DJANGO_SETTINGS_MODULE in environment variable. Eg. DJANGO_SETTINGS_MODULE=config.settings

    Note: You must have django_extensions installed

import sys; print('Python %s on %s' % (sys.version, sys.platform))
import django; print('Django %s' % django.get_version())
from django.core.management.color import no_style
from django_extensions.management.shells import import_objects

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)
globals().update(import_objects({}, no_style()))
  1. You may also want to set clear shortcut of pycharm,

    • Search "Clear All" and set the shortcut.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment