This document is written for Django version 1.11. When you look for Django documentation, make sure that you the docs version matches the version you're using because there are significant version differences. Eclipse PyDev Re-configuration Because of the Django Python software additions, we need to reset PyDev's PYTHONPATH environment variable. The sources for the PyDev.Debugger (used in PyDev & PyCharm) may be seen at. It should be compatible with Python 2.6 onwards (as well as Jython 2.7, IronPython. Then get the latest Pydev release (a zip containing org.python.pydev., com.python.pydev. folders) from pydev.org. Copy that stuff to the appropriate folders, where also the old, above installed version is located (/usr/lib/eclipse/features and /usr/lib/eclipse/plugins). It should be obvious what belongs where.
To get started with Django in PyDev, the pre-requisite is that Django is installed in the Python / Jython / IronPython interpreter you want to use (so, 'import django' must properly work – if you're certain that Django is there and PyDev wasn't able to find it during the install process, you must go to the interpreter configuration and reconfigure your interpreter so that PyDev can detect the change you did after adding Django).
If you don't have Django installed, follow the steps from http://www.djangoproject.com/.
Note that this tutorial won't teach you Django. It'll only show how the Django integration is available in PyDev, so, if you're not familiar with Django, it's useful to learn a bit about how it works and then use this help to know how the PyDev Django integration can help you.
The Django integration in PyDev works through 3 main configurations:
1. The project must be marked as a Django project inside of PyDev.
2. A DJANGO_MANAGE_LOCATION string substitution variable must point to the project-relative location of manage.py.
3. A DJANGO_SETTINGS_MODULE string substitution variable must contain the name of the settings module in that project.
And that's it, with those properly configured, all the Django-related actions should work (provided the project is already configured as a Django project, there's an UI to configure those settings in the project properties: right-click your project > properties > PyDev - Django)
Use the new project wizard through Ctrl+N > PyDev Django ProjectAmazon photos apple tv. to create a new Django based project.
That wizard will use django-admin.py startproject to create the project and will properly set the string substitution variables used inside of PyDev so that DJANGO_MANAGE_LOCATION points to the created manage.py location and the DJANGO_SETTINGS_MODULE points to the settings module.
For an existing project, just right click it and choose 'PyDev > Set as Django project'.
Note that the DJANGO_MANAGE_LOCATION and DJANGO_SETTINGS_MODULE will not be set at this time, but when executing an action that needs it, PyDev will ask about it.
Django actions can be accessed right clicking a project with the Django configuration and choosing Django > action.
Another option is using (with focus on a PyDev editor):
- ctrl+2+dj <enter> to open a dialog with the history of entered actions
- ctrl+2+dj action_to_execute <enter> to already pass the action to be executed (e.g.: ctrl+2+dj help <enter>)
Note that the Shell with django environment action will create a shell properly configured with your settings, providing the default features from the PyDev shell, such as code completion, history, context assistants (ctrl+1), making an execfile of the editor, etc (see: Interactive Console for more details).
It can be activated through ctrl+2+dj shell (if on a PyDev Editor) or right-clicking the project > Django > Shell with django environment.
Run as Django/Debug as Django are available (note that they set the --noreload by default).
This will create a default Run configuration, so, you may edit it later through run > run configurations (or debug > debug configurations) if you want to change a parameter.
Note: to know how to rerun the last launch see: the Rerun Last Launch topic on PyDev Launching
Python In Eclipse
Note 2: if the --noreload is not passed, only the parent process will be killed from Eclipse and the others will only be killed when they'd be reloaded (i.e.: on a code-change).
Pydev Django Template Editor
It's possible to run Django using it's auto-reload feature.
Note: make sure you have PyDev 3.4.1 or or a more recent version for that (which added multiprocessing debugging by default and kills children processes properly).
If you have some issue, make sure that in the preferences > PyDev > Run/Debug, 'Attach to subprocess automatically while debugging?' is checked and 'When terminating process, kill suprocesses too?' is also checked.
Also, if you have a launch from a previous version, either go to Run > Run Configurations and remove existing launches (to recreate them) or remove the -noreload from the arguments in existing launches.
So, doing that, starting the remote debugger and making a debug run should enable all the regular breakpoints that are put inside Eclipse to work in the Django process and to see changes done without the need for restarting the application.