Had both python and django console menu options in PyCharm in 3.4. Just switched to PyCharm 4 and the "Django Console" entry is gone. Do I have to activate it somewhere?
Trying to run django code within the python console leads to the usual error of settings module not having been configured. HEnce, the "automatic detection" does nit work.
DJANGO_SETTINGS_MODULE is set correctly in /manage.py and main_module/uwsgi.py to point to "main_module.settings"
The project has been created with PyCharm 3.x. Maybe it does not detect the project for some reason as being a django project? Everything else seems to work fine: running django server, templates compeltion, etc.
I had the same problem and I found the solution by examining the settings of a newer project (created in a later version of PyCharm).
Put the following code in your Django Console settings (Settings > Build, Execution, Deployment > Console > Django Console > Starting script):
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])
if 'setup' in dir(django): django.setup()
import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)
This code is there by default when the project is made in a newer PyCharm.
It was incapsulated in Python console
. You can test you Django app in Python console.
From JetBrains Blog
Improved Python/Django console tool window
PyCharm automatically detects which type of the console should be run depending on your project type and context. The console can be launched via the tools window menu as shown on the picture below or using the “Ctrl+ E” shortcut:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With