Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Django PDB
==========

Make debugging Django easier
----------------------------

Adding ``pdb.set_trace()`` to your source files every time you want to break into pdb sucks.

Don't do that.

Do this.

Installation
------------

Install using pip::

pip install django-pdb

Add to your django project::

INSTALLED_APPS = (
...
'django_pdb',
)

Usage
-----

``manage.py runserver``

Drops into pdb at the start of a view if the URL includes a `pdb` GET parameter.

Drops into ipdb at the start of a view if the URL includes a `ipdb` GET parameter.

This behavior is only enabled if ``settings.DEBUG = True``::

bash: testproject/manage.py runserver
Validating models...

0 errors found
Django version 1.3, using settings 'testproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

GET /test?pdb
function "myview" in testapp/views.py:7
args: ()
kwargs: {}

> /Users/tom/github/django-pdb/testproject/testapp/views.py(8)myview()
-> a = 1
(Pdb)

``manage.py runserver --pdb`` **or** ``manage.py runserver --ipdb``::

Drops into pdb/ipdb at the start of every view::

bash: testproject/manage.py runserver --pdb
Validating models...

0 errors found
Django version 1.3, using settings 'testproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

GET /test
function "myview" in testapp/views.py:7
args: ()
kwargs: {}

> /Users/tom/github/django-pdb/testproject/testapp/views.py(7)myview()
-> a = 1
(Pdb)


``manage.py test --pdb`` **or** ``manage.py test --ipdb``

Drops into pdb/ipdb on test errors/failures::

bash: testproject/manage.py test testapp --pdb
Creating test database for alias 'default'...
E
======================================================================
>>> test_error (testapp.tests.SimpleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/tom/github/django-pdb/testproject/testapp/tests.py", line 16, in test_error
one_plus_one = four
NameError: global name 'four' is not defined
======================================================================

> /Users/tom/github/django-pdb/testproject/testapp/tests.py(16)test_error()
-> one_plus_one = four
(Pdb)


Other apps that override runserver
----------------------------------

If you also use other apps that override the runserver command, but still want to use `django-pdb`...

Add the following to your settings.py::

if DEBUG:
MIDDLEWARE_CLASSES += ('django_pdb.middleware.PdbMiddleware',)

And make sure that ``django_pdb`` comes before any conflicting apps in ``INSTALLED_APPS``.

Metadata

Release files for django-pdb 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for django-pdb 0.2.1
File Size Uploaded
django-pdb-0.2.1.zip 9.4 kB Details
django-pdb-0.2.1.tar.gz 5.0 kB Details

Release files / django-pdb-0.2.1.zip

Download URL django-pdb-0.2.1.zip
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
20f2c3fe489bedfa43fbcd76359edd24989fca722232412e643e6756acb0766a
BLAKE2b-256 checksum
How to use checksums
bdb44e59e2c1ebeb03e276f29c78cbfcee685e03fdc06ed2066df9c8ee7bd556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django-pdb-0.2.1.tar.gz

Download URL django-pdb-0.2.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e3f8485cb765969e4f36c3a63f8c2e8f587f113f820c6e25b8bf05dea4598889
BLAKE2b-256 checksum
How to use checksums
1805bb064725157759cc29dda24df9a46f88647f395c7444b9c6d893eedfed38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page