PyCharm tips

View print output immediatly

Add PYTHONUNBUFFERED=1 in run config or .env (only use .env if you use the plugin). This is meant to immediately view the output of the print function without the need for flush=True.

Autoload .env file

  • Install the EnvFile and .env file support plugins. Then configure the Django server to run with the custom command runserver_plus (optional) and in the EnvFile tab, tick Enable EnvFile and in the box below, add you .env file. Do the same for pytest.

  • Use [direnv]( to autoload the .env. To do this, create a .envrc file with the content below and run direnv allow . to allow the .envrc file to be loaded:

    # Auto load venv.
    # Auto load .env file
  • Add this to the activate script:

if [[ "${TERMINAL_EMULATOR}" == "JetBrains-JediTerm" && -f .env ]]; then
    load-dotenv .env

Use shell_plus in the integrated console

Use this starting script in Build, Execution, Deployment > Console > Django console:

# Load env var
import environ

import sys; print('Python %s on %s' % (sys.version, sys.platform))
import django; print('Django %s' % django.get_version())
if 'setup' in dir(django): django.setup()
import django_manage_shell;
from import shells
from import color_style

# Default settings for shell_plus
shell_plus_default_settings = {
    'bpython':         False,
    'connection_file': None,
    'dont_load':       [],
    'ipython':         True,
    'kernel':          False,
    'no_browser':      False,
    'no_color':        False,
    'notebook':        False,
    'plain':           False,
    'print_sql':       False,
    'ptipython':       False,
    'ptpython':        False,
    'pythonpath':      None,
    'quiet_load':      False,
    'settings':        None,
    'traceback':       False,
    'use_pythonrc':    False,
    'verbosity':       1,
    'vi_mode':         False,
    'dont_load':       [],

g = globals()
objects_to_import = shells.import_objects(shell_plus_default_settings, color_style())