Skip to main content

UNKNOWN

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

django-pdb-0.2.2.zip (9.3 kB view details)

Uploaded Source

django-pdb-0.2.2.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file django-pdb-0.2.2.zip.

File metadata

  • Download URL: django-pdb-0.2.2.zip
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-pdb-0.2.2.zip
Algorithm Hash digest
SHA256 e152248ff11bb6d8e3178c6acff192c6a9c71fc028ba5a3aa0f494c04ad01acb
MD5 3b97d17fa8cdf36ee75805623bf14873
BLAKE2b-256 10f14d8ec8dc29f025339656317c9fe1f73dfaa7bc389d1a35b5d4f0cbe56b52

See more details on using hashes here.

File details

Details for the file django-pdb-0.2.2.tar.gz.

File metadata

  • Download URL: django-pdb-0.2.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-pdb-0.2.2.tar.gz
Algorithm Hash digest
SHA256 02e8e7d204df5ffea3e8d029bc785a46ed0f41a5a252649f080d7fe7b4378b08
MD5 fdb609f674aeab837ff6d916d7e670b9
BLAKE2b-256 103c82ed5553706ca50d6e1571f9e0620201bbe8ddd476ccc3c33dc8b51fbeb1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page