How to enable Eclipse debugging features in a web application?

I am using the Django framework for my Python web application using the Eclipse IDE and PyDev plugin. How to use debugging features?

UPDATES1 especially using the http://pydev.org/updates plugin

UPDATES2 I have already done the following:

.pydevproject

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?eclipse-pydev version="1.0"?> <pydev_project> <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Python25 </pydev_property> <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5 </pydev_property> <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> <path>/pi-proto</path> </pydev_pathproperty> <pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH"> <path>C:\Program Files\GeoDjango\Django-1.0.2-final</path> <path>C:\eclipse-SDK-3.7-win32\plugins\org.python.pydev.debug_2.2.3.2011100616\pysrc </path> </pydev_pathproperty> </pydev_project> 

manage.py

 #!/usr/bin/env python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it causing an ImportError somehow.)\n" % __file__) sys.exit(1) if __name__ == "__main__": import sys if len(sys.argv) > 1: command = sys.argv[1] if settings.DEBUG and (command == "runserver" or command == "testserver"): # Make pydev debugger works for auto reload. try: import pydevd except ImportError: sys.stderr.write("Error: " + "You must add org.python.pydev.debug.pysrc to your PYTHONPATH.") sys.exit(1) from django.utils import autoreload m = autoreload.main def main(main_func, args=None, kwargs=None): import os if os.environ.get("RUN_MAIN") == "true": def pydevdDecorator(func): def wrap(*args, **kws): pydevd.settrace(suspend=False) return func(*args, **kws) return wrap main_func = pydevdDecorator(main_func) return m(main_func, args, kwargs) autoreload.main = main execute_manager(settings) 

Run Configurations - Arguments

 runserver 0.0.0.0:8001 

UPDATES3 I follow this link http://bear330.wordpress.com/2007/10/30/how-to-debug-django-web-application-with-autoreload/

But no success. Would you advise me how to properly follow the link above. Then I will update the result here.

UPDATES4 I am using Python 2.5.2, GeoDjango 1.2.7, Eclipse Indigo with the PyDev plugin.

+3
source share
2 answers

To configure PyDev to work with Django, see http://pydev.org/manual_adv_django.html

So, if you run without the automatic restart function (which PyDev will do automatically when you create a new Django launch), you can do everything directly (that is, the debugger and startup do not need any special settings).

Now, if you want to enable startup at development time, use the tips at: PyDev and Django: how to restart the dev server? (to overcome the question of when Django will leave child processes alive when the main process is killed)

And look at the session associated with the remote debugger at: http://pydev.org/manual_adv_remote_debugger.html to see how to connect the debugger to PyDev when using auto-reload (basically, you need to start the remote debugger, but it will be regular add breakpoints, and PyDev will stop at the ones you call pydevd.patch_django_autoreload () before the main session).

+1
source

Source: https://habr.com/ru/post/1346985/


All Articles