Skip to content

Instantly share code, notes, and snippets.

@Louis-Saglio
Created December 2, 2019 18:34
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 Louis-Saglio/33a4eb4207f33a76c9c6b1ed44bb1cc1 to your computer and use it in GitHub Desktop.
Save Louis-Saglio/33a4eb4207f33a76c9c6b1ed44bb1cc1 to your computer and use it in GitHub Desktop.
Django console starting script for Pycharm with docker interpreter
When a Django project is configured with an interpreter located in a docker container, the python console encounter errors.
To fix that, go to file > settings > Build, Execution, Deployment > Console > Django Console.
Then override the starting script with the following snippet :
import sys; print('Python %s on %s' % (sys.version, sys.platform))
import django; print('Django %s' % django.get_version())
sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS, '/opt/.pycharm_helpers/pycharm', '/opt/.pycharm_helpers/pydev'])
if 'setup' in dir(django): django.setup()
import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment