Skip to content

Instantly share code, notes, and snippets.

@andrelcunha
Forked from biwin/community_to_shell.py
Created September 5, 2017 19:27
Show Gist options
  • Save andrelcunha/fbb11b5064b00585ebaa5b7d728b2603 to your computer and use it in GitHub Desktop.
Save andrelcunha/fbb11b5064b00585ebaa5b7d728b2603 to your computer and use it in GitHub Desktop.
Use PyCharm community Python Console as Django Shell.
# Change the run script on `settings> Build Execution and Deployment > Console > Python Console` to
# hoping you have your settings at project/project/settings.py (if not, change accordingly;)
import os,sys,django;sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])
os.environ['DJANGO_SETTINGS_MODULE'] = WORKING_DIR_AND_PYTHON_PATHS.split('/')[-1]+'.settings'
print('Python {0} on {1} using {2} as settings'.format(sys.version, sys.platform, os.environ['DJANGO_SETTINGS_MODULE']))
django.setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment