Skip to content

Instantly share code, notes, and snippets.

@bzdk
Forked from biwin/community_to_shell.py
Created December 23, 2019 02:21
Show Gist options
  • Save bzdk/c4e4f7aec697993e98ae273619ba7b78 to your computer and use it in GitHub Desktop.
Save bzdk/c4e4f7aec697993e98ae273619ba7b78 to your computer and use it in GitHub Desktop.
Change PyCharm Community Python Console to PyCharm Professional Django Console (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