Skip to main content

Gives you `manage.py runserver --pdb` and `manage.py test --pdb`

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. settings.DEBUG must be 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:6
args: ()
kwargs: {}

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

manage.py runserver --pdb

Drops into pdb 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:6
args: ()
kwargs: {}

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

manage.py test --pdb

Drops into pdb 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)

Project details


Download files

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

Source Distribution

django-pdb-0.1.2.tar.gz (4.2 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for django-pdb-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d543d5c03d7eae3bae034d91e5f7a8ea294f717044e05099169b2987b0a258c1
MD5 85f0b3b37a45c2f2e12b095a5786dac6
BLAKE2b-256 6a1cae6d4b1817f833c9f84d7b56ee7f7f6bf80928e5cc340e0ad3e6b3a40be3

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