Re: Debugging Django
For a range of debugging options available for WSGI applications, including how to get things like pdb to run in the context of Apache, see: http://code.google.com/p/modwsgi/wiki/DebuggingTechniques Graham On Nov 10, 5:04 am, [EMAIL PROTECTED] wrote: > On Fri, Nov 09, 2007 at 08:32:15AM -0700, John M. Anderson wrote: > > > You cannot debug a single Django file in isolation. Instead, insert this > > > line: > > > >import pdb; pdb.set_trace() > > > > in sql.py, at the point you're interested in. Then run Django normally, > > > and > > > go to a db-based URL: you'll get a debugger prompt. > > > ok, thanks. I was just trying to debug without modifying files, it seems > > silly > > to have to modify the files to debug, but i'm new to python. > > If you are new to python: You don't need a debugger. > > Set up your servert, so that code gets reloaded automatically (either > 'manage.py > runserver' or mod_python with 'MaxRequestsPerChild 1'). Then > you can add 'assert False' or for example > 'assert False, django.db.connection.queries' into the code you want > to inspect. This will give you a lot of information if DEBUG=True is > set in settings.py. > > Or: you can set up the logging module and add lines like > logging.info("foo: %s" % (foo)) into the code. > > If you are new to python and django, you can ask on the user mailinglist > first. > > Thomas > > -- > Thomas Guettler,http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: Debugging Django
On Fri, Nov 09, 2007 at 08:32:15AM -0700, John M. Anderson wrote: > > You cannot debug a single Django file in isolation. Instead, insert this > > line: > > > >import pdb; pdb.set_trace() > > > > in sql.py, at the point you're interested in. Then run Django normally, > > and > > go to a db-based URL: you'll get a debugger prompt. > > > > ok, thanks. I was just trying to debug without modifying files, it seems > silly > to have to modify the files to debug, but i'm new to python. If you are new to python: You don't need a debugger. Set up your servert, so that code gets reloaded automatically (either 'manage.py runserver' or mod_python with 'MaxRequestsPerChild 1'). Then you can add 'assert False' or for example 'assert False, django.db.connection.queries' into the code you want to inspect. This will give you a lot of information if DEBUG=True is set in settings.py. Or: you can set up the logging module and add lines like logging.info("foo: %s" % (foo)) into the code. If you are new to python and django, you can ask on the user mailinglist first. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: Debugging Django
> You cannot debug a single Django file in isolation. Instead, insert this > line: > >import pdb; pdb.set_trace() > > in sql.py, at the point you're interested in. Then run Django normally, > and > go to a db-based URL: you'll get a debugger prompt. > ok, thanks. I was just trying to debug without modifying files, it seems silly to have to modify the files to debug, but i'm new to python. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Re: Debugging Django
John M. Anderson wrote: > I'm trying to debug sql.py > > the steps I've taken so far: > > python /usr/lib/python2.5/pdb.py manage.py sql polls > (python manage.py polls works just fine) You cannot debug a single Django file in isolation. Instead, insert this line: import pdb; pdb.set_trace() in sql.py, at the point you're interested in. Then run Django normally, and go to a db-based URL: you'll get a debugger prompt. -- Nicola Larosa - http://www.tekNico.net/ I grew up with the colonialist propaganda, the "occupier's narrative", and it took me half my life to realize it was all a lie. [...] If I were among those directly afflicted by the genocide, paternalism, exploitation, theft and abuse committed every day by colonial invaders, in almost every nation on the planet, I would be consumed by rage. [...] We should be ashamed of ourselves. -- Dave Pollard, July 2007 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Debugging Django
I'm trying to debug sql.py the steps I've taken so far: python /usr/lib/python2.5/pdb.py manage.py sql polls (python manage.py polls works just fine) (Pdb) b django/core/management/sql.py:271 (Pdb) c Traceback (most recent call last): File "/usr/lib/python2.5/pdb.py", line 1213, in main pdb._runscript(mainpyfile) File "/usr/lib/python2.5/pdb.py", line 1138, in _runscript self.run(statement, globals=globals_, locals=locals_) File "/usr/lib/python2.5/bdb.py", line 366, in run exec cmd in globals, locals File "", line 1, in File "./manage.py", line 11, in execute_manager(settings) File "/usr/local/lib/python2.5/site-packages/django/core/management/__init__.py", line 275, in execute_manager project_directory = setup_environ(settings_mod) File "/usr/local/lib/python2.5/site-packages/django/core/management/__init__.py", line 255, in setup_environ project_module = __import__(project_name, {}, {}, ['']) ValueError: Empty module name Uncaught exception. Entering post mortem debugging Running 'cont' or 'step' will restart the program > /usr/local/lib/python2.5/site-packages/django/core/management/__init__.py(255)setup_environ() -> project_module = __import__(project_name, {}, {}, ['']) What module name is invalid? does pdb change the way my environment works? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~--~~~~--~~--~--~---
Debugging Django
I'd love to help with the Django development. If I encounter a Traceback in the admin interface, how would you recommend I start debugging? Running the webserver in Komodo's debug mode fails since multi-thread debugging is not supported. Is there a way to "simulate" a request for a page like http://localhost:8000/admin/myproject/tasks/ that allows setting breakpoints?