hassenpy / django-pdb Goto Github PK
View Code? Open in Web Editor NEWGives you `manage.py runserver --pdb` and `manage.py test --pdb`
Gives you `manage.py runserver --pdb` and `manage.py test --pdb`
Hi,
I'm unable to make it work with my django 1.10.3 setup.
I have added it to top of the INSTALLED_APPS.
INSTALLED_APPS = [
'django_pdb',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django_countries',
'haystack',
and have added middleware class at the end :
MIDDLEWARE_CLASSES += ('django_pdb.middleware.PdbMiddleware',)
When I run it python manage.py runserver 0.0.0.0:8000 --pdb
, it doesn't drop me into pdb shell.
Can anyone please help me in debugging why it's not working ? Is it a bug ? Or is it a configuration issue at my end ?
Regards,
Ashish Bansal
Hi Mitch,
maybe when you have time pls update this source code to be compatible with python 3 and the rest of them etc. Currently not working :( and it sucks cos it gaves a lot of errors.
Hey there! Cheers for the package, looking forward to using it, I noticed that #42 was merged in March but the releases on Github list the last official release as happened in July 2017. Can we get a version bump for those of us using pip/pipenv?
Thanks mate.
After installing this package, runserver
commands raises the following error related with MIDDLEWARE_CLASSES
.
python manage.py runserver
Traceback (most recent call last):
File "site/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/(the path)/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/(the path)/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/(the path)/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/(the path)/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 62, in execute
super().execute(*args, **options)
File "/(the path)/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/(the path)/lib/python3.6/site-packages/django_pdb/management/commands/runserver.py", line 61, in handle
middleware = settings.MIDDLEWARE_CLASSES
File "/(the path)/lib/python3.6/site-packages/django/conf/__init__.py", line 57, in __getattr__
val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'MIDDLEWARE_CLASSES'
My environment is:
This may be related to #40. Thank you in advance.
I see this tool already has support for pdb
and ipdb
.
Would it be possible to add support for pudb
? https://pypi.python.org/pypi/pudb
If a CBV is debugged using the pdb
or ipdb
GET parameter, the console drops into the debugger in the view()
function inside the django.views.generic.base.View.as_view()
method closure. It takes a few careful steps to end up in actual view code of the application.
Off the top of my head, I can't think of an easy way to make it run a little further and only break when view code outside the Django core is entered. However, it would be very useful if that was possible.
File "/xx/lib/python3.6/site-packages/django_pdb/utils.py", line 15, in get_ipdb return ipdb.__main__.Pdb(def_colors)
AttributeError: module 'ipdb.__main__' has no attribute 'Pdb'
test not ok when: pip install ipdb >=0.11
test ok when: pip install ipdb==0.10
Django-pdb works fine, but I have a custom .pythonrcfile which allows nice features like autocomplete when I set_trace manually. Any ideas on how I can pull this off with python manage.py test --pdb?
If you can give me a place to start I can try and see if I can create a fix for it myself. Thanks for all you do!
It would be nice if I could press Ctrl-C to break into the running code.
This would be really helpful for example in debugging complicated or long-running views.
Steps to reproduce:
The following traceback is generated:
Traceback (most recent call last):
File "./manage.py", line 14, in <module>
execute_manager(settings)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django_pdb-0.1.2-py2.6.egg/django_pdb/management/commands/test.py", line 2, in <module>
from django_pdb.testrunners import PdbTestSuiteRunner
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django_pdb-0.1.2-py2.6.egg/django_pdb/testrunners.py", line 70, in <module>
class PdbTestResult(ExceptionTestResultMixin, unittest._TextTestResult):
AttributeError: 'module' object has no attribute '_TextTestResult'
This can be fixed in one of two ways:
from django.utils import unittest
instead of import unittest
, and depending on Django >= 1.3.if sys.version_info[:2] < (2, 7): import unittest2 as unittest
and depending on unittest2 if Python version is less than 2.7.Hi
I tested your app - seems great, but it does not currently work with django 1.2/1.3 static files apps. Could you update it to do so?
Thanks
Tim
AttributeError: 'PdbMiddleware' object has no attribute '_is_coroutine'
seems to be coming from not calling super().__init__()
in the PdbMiddleware
I added line 41 - first line in the __init__functon:
def __init__(self, get_response=None, debug_only=True):
"""
If debug_only is True, this middleware removes itself
unless settings.DEBUG is also True. Otherwise, this middleware
is always active.
"""
super().__init__(get_response)
self.get_response = get_respose
if debug_only and not settings.DEBUG:
raise MiddlewareNotUsed()
that in turn calls _async_check()
correctly from class deprecation.MiddlewareMixin
Just wondering if this works with ipdb as well? TIA
The tests are failing on Django 3.x
+ python3 testproject/manage.py test
Traceback (most recent call last):
File "testproject/manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3.8/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "/usr/lib/python3.8/site-packages/django/core/management/base.py", line 322, in run_from_argv
parser = self.create_parser(argv[0], argv[1])
File "/usr/lib/python3.8/site-packages/django/core/management/base.py", line 296, in create_parser
self.add_arguments(parser)
File "/home/abuild/rpmbuild/BUILDROOT/python-django-pdb-0.6.2-12.1.x86_64/usr/lib/python3.8/site-packages/django_pdb/management/commands/test.py", line 39, in add_arguments
parser.add_argument(name, **kwargs)
File "/usr/lib64/python3.8/argparse.py", line 1386, in add_argument
return self._add_action(action)
File "/usr/lib64/python3.8/argparse.py", line 1749, in _add_action
self._optionals._add_action(action)
File "/usr/lib64/python3.8/argparse.py", line 1590, in _add_action
action = super(_ArgumentGroup, self)._add_action(action)
File "/usr/lib64/python3.8/argparse.py", line 1400, in _add_action
self._check_conflict(action)
File "/usr/lib64/python3.8/argparse.py", line 1539, in _check_conflict
conflict_handler(action, confl_optionals)
File "/usr/lib64/python3.8/argparse.py", line 1548, in _handle_conflict_error
raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --pdb: conflicting option string: --pdb
Hello, I'd like to know if the project is still active. If not, I'd love to be a maintainer and update and add new features.
Hello
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
TypeError: 'PdbMiddleware' object is not callable
Django: 1.10.3 / Django-Pdb: 0.5.1
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'devices',
'rest_framework',
'django_pdb'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django_pdb.middleware.PdbMiddleware',
]
Thank you
It would be very handy to have a template tag you could use to put a breakpoint in a Django template as explained here: http://opensourcehacker.com/2013/05/16/putting-breakpoints-to-html-templates-in-python/
The latest releases on PyPI are 0.6.2, 0.6.1, 0.5.1
The latest tags here are v6.1, v6.0, 0.4.1
I assume tag v6.1 == PyPI 0.6.1.
And that PyPI 0.6.2 has no tag on Github.
The order of loading the management commands changed:
https://docs.djangoproject.com/en/dev/releases/1.7/#management-commands-and-order-of-installed-apps
This probably also means that the internal commands get registered first.
Breakpoints never seem to be hit when another middleware class returns a response, which makes sense given the docs:
If it returns an HttpResponse object, Django won’t bother calling any other view or exception middleware, or the appropriate view
Is this a known limitation?
Hi Tom (and co),
I've forked this project to
https://github.com/0atman/django-pdb-pudb
And done little more than s/pdb/pudb
I wanted to reach out to you and the community to make sure I'm doing the right thing with attribution, I've not done much to add value to the code!
I've also dropped it on PyPi for convenience. https://pypi.python.org/pypi/django-pdb-pudb
I've been using django-pdb for a while, and I'm really please to integrate my new favourite tool, pudb! Thanks for your help guys :-)
Respect settings.TEST_RUNNER setting:
https://docs.djangoproject.com/en/dev/ref/settings/#test-runner
I get the following deprecation warning while using Django 1.8 ,
django.utils.unittest will be removed in Django 1.9
I would like to use with e.g. manage.py makemigrations
, too.
(py36dj20) swot@pp:~/pp/zlhopesun$ python manage.py runserver --ipdb
Performing system checks...
System check identified no issues (0 silenced).
May 06, 2018 - 02:15:34
Django version 2.0.4, using settings 'XService.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
GET /custom_login/
function "LoginView" in generic/base.py:54
args: ()
kwargs: {}
/home/swot/venv/py36dj20/lib/python3.6/site-packages/IPython/frontend.py:21: ShimWarning: The top-level frontend
package has been deprecated since IPython 1.0. All its subpackages have been moved to the top IPython
level.
"All its subpackages have been moved to the top IPython
level.", ShimWarning)
Internal Server Error: /custom_login/
Traceback (most recent call last):
File "/home/swot/venv/py36dj20/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/swot/venv/py36dj20/lib/python3.6/site-packages/django/core/handlers/base.py", line 119, in _get_response
response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/swot/venv/py36dj20/lib/python3.6/site-packages/django_pdb/middleware.py", line 83, in process_view
p = get_ipdb()
File "/home/swot/venv/py36dj20/lib/python3.6/site-packages/django_pdb/utils.py", line 15, in get_ipdb
return ipdb.main.Pdb(def_colors)
AttributeError: module 'ipdb.main' has no attribute 'Pdb'
[06/May/2018 02:19:18] "GET /custom_login/ HTTP/1.1" 500 82881
/home/swot/venv/py36dj20/lib/python3.6/site-packages/IPython/html.py:14: ShimWarning: The IPython.html
package has been deprecated since IPython 4.0. You should import from notebook
instead. IPython.html.widgets
has moved to ipywidgets
.
"IPython.html.widgets
has moved to ipywidgets
.", ShimWarning)
Hi, when i enable this app on project with south enabled, looks like it breakes it
can you check.
[edit - tomchristie: updated title of ticket]
Had an issue where middleware wasn't honoured in django 3.6.3. Stock install from pypi fails with the error below. This fixes that.
Traceback (most recent call last):
File "./manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/chayim/.venvs/python/3.6.3.siemphony.core.master/lib/python3.6/site-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/home/chayim/.venvs/python/3.6.3.siemphony.core.master/lib/python3.6/site-packages/django/core/management/init.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/chayim/.venvs/python/3.6.3.siemphony.core.master/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/chayim/.venvs/python/3.6.3.siemphony.core.master/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 62, in execute
super(Command, self).execute(*args, **options)
File "/home/chayim/.venvs/python/3.6.3.siemphony.core.master/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/chayim/.venvs/python/3.6.3.siemphony.core.master/lib/python3.6/site-packages/django_pdb/management/commands/runserver.py", line 62, in handle
if middlware is None:
I use django-devserver, which also replaces runserver.
You should document that in order to use django_pdb with something that overrides runserver (or test), you can just do:
MIDDLEWARE_CLASSES += ('django_pdb.middleware.PdbMiddleware',)
And ensure that django_pdb is installed before the other app that overrides the runserver command.
(Being able to --werkzeug with devserver makes it fully awesome).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.