Skip to content

Instantly share code, notes, and snippets.

@willianantunes
Created March 2, 2019 16:21
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 willianantunes/e5c70df433a9854c1d9153ec487719dc to your computer and use it in GitHub Desktop.
Save willianantunes/e5c70df433a9854c1d9153ec487719dc to your computer and use it in GitHub Desktop.
Starting script to enable Django Console in IntelliJ IDEA Ultimate
import os
import sys
from runpy import run_module
import django
from django.core import management
print(f"Python {sys.version} on {sys.platform}")
print(f"Django {django.get_version()}")
print(f"Current dir: {os.getcwd()}")
def execute_django_manage_file():
def execute_from_command_line_stub(argv=None):
pass
management.execute_from_command_line = execute_from_command_line_stub
django_manage_file = os.getenv('PYCHARM_DJANGO_MANAGE_MODULE')
if not django_manage_file:
django_manage_file = 'manage'
run_module(
mod_name=django_manage_file,
init_globals=None,
run_name='__main__',
alter_sys=True,
)
django.setup()
execute_django_manage_file()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment