jkhoo
jkhoo

Reputation: 31

How to amend the default starting script for Django Console in Pycharm

How do I amend the default starting script for Django Console in Pycharm? The starting script defaults to the following every time I start a new project.

import sys; print('Python %s on %s' % (sys.version, sys.platform))
import django; print('Django %s' % django.get_version())
import os
os.environ.setdefault("DATABASE_URL","postgres://{}:{}@{}:{}/{}".format(os.environ['POSTGRES_USER'], os.environ['POSTGRES_PASSWORD'], os.environ['POSTGRES_HOST'], os.environ['POSTGRES_PORT'], os.environ['POSTGRES_DB']))
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)

Is there a way to change this default script?

I've tried to do so under File>Default Settings, but there is only Python console listed here; Django console isn't listed.

Edit 1: I guess I wasn't clear enough. I want to change the default setting, rather than to have do this every time I start a new project. So how do I change this so that new projects would reflect my intended starting script automatically?

Edit 2: I found that what I needed to do is to amend the workspace.xml file inside the .idea folder, but this is at the project level, not a default setting level.

Haven't found out how to do this on a global basis.

Upvotes: 1

Views: 342

Answers (1)

jTiKey
jTiKey

Reputation: 743

Defaults are here: Other settings -> settings for new projects but true, there's no django console.

You could request the pycharm team to add it. https://intellij-support.jetbrains.com/hc/en-us

Upvotes: 1

Related Questions