Skip to main content

Tools for debugging Django, pprint models

Project description

Tools for debugging Django

Summary

  • dorm: Pretty print models, querysets, etc.

  • ds: Search dictionaries and lists for string.

  • ago: Generate datetimes.

DORM - Debug Django ORM

Pretty print django objects with syntax highlighting, column layout and shorthands.

Dorm can handle: - model instances + attribute coloring + grouping + attribute values + print in parallel columns - querysets + print all rows in queryset + prints selected values (in values=[] fashion) or value from ‘callable’ + paginate, with skipt to page - query + syntax highlight - list / dict / tuple through pprint

Requirements

  • Python 2

  • Django

  • sqlparse

Installation

$ pip install djangodbu

Usage

Start Django shell_plus: python manage.py shell_plus

>>> from djangodbu import dorm
>>> dorm(MyModel.objects.get(id=123))
         instancemethod serializable_value
         instancemethod set_password
         instancemethod set_unusable_password
         instancemethod unique_error_message
         instancemethod validate_unique
                unicode USERNAME_FIELD: username
                unicode email: some.one@example.org
                unicode first_name: Some
                unicode last_name: One
                unicode password: pbkdf2_sha256$20000$
                unicode username: someone
                   list REQUIRED_FIELDS: 1
                   long id: 357
                   long pk: 357
so.mo.na.AccountingUser accountinguser: 651 > 'Some One'
         RelatedManager additionalemail_set: 1
         RelatedManager callback_set: 0
         RelatedManager campaigncode_set: 0
         RelatedManager grouplog: 142
     ManyRelatedManager groups: 0
         RelatedManager log: 379
         RelatedManager logevent_set: 89
         RelatedManager message_set: 11
       lo.pa.to.Payment payment: 510 > 'Bob & Uncle'
         RelatedManager settings_set: 1
         RelatedManager social_auth: 0
     ManyRelatedManager user_permissions: 0
         RelatedManager worker_set: 1
               NoneType activationcode
               NoneType auth_token
               NoneType employee
                   bool is_active: True
                   bool is_superuser: False
      datetime.datetime date_joined: 2016-05-01 08:13:16+00:00
      datetime.datetime last_login: 2016-06-20 07:48:51+00:00
                   type DoesNotExist: DoesNotExist
               classobj Meta: Meta
                   type MultipleObjectsReturned: MultipleObjectsReturned

Printing QuerySets:

>>> dorm(MyModel.objects.all())
1: userA
2: userB
4: userD
20: userY
...

Selecting values for QuerySet:

>>> dorm(User.objects.all(), v='first_name, email')

    id: firstname  email
------------------------------------------------
    1: abcd       userA@example.org
    2: efghij     userB@example.org
    4: kl         userD@example.org
    20: Mnopqrst  userY@example.org
...

Print Query:

>>> dorm(User.objects.filter(email__isnull=False).exclude(first_name='kl').query)
SELECT auth_user.id,
       auth_user.password,
       auth_user.username,
       auth_user.first_name,
       auth_user.last_name,
       auth_user.email
FROM auth_user WHERE (auth_user.email IS NOT NULL
       AND NOT (auth_user.first_name = kl))

Project url

djangodbu on github

djangodbu on pypi

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

djangodbu-0.0.17.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

djangodbu-0.0.17-py2-none-any.whl (21.6 kB view details)

Uploaded Python 2

File details

Details for the file djangodbu-0.0.17.tar.gz.

File metadata

  • Download URL: djangodbu-0.0.17.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.15

File hashes

Hashes for djangodbu-0.0.17.tar.gz
Algorithm Hash digest
SHA256 57575d0eb23ed6fdf995ac023394fb9f0dbc0b005470e7a6e34b8457ae1d181b
MD5 df945bbf8dcec52772ed1bfda53f896d
BLAKE2b-256 7b72f5fa1dcd3be7d656905f6cd7e296f463ad3c8b85a0f17d599a95c8a1bf69

See more details on using hashes here.

File details

Details for the file djangodbu-0.0.17-py2-none-any.whl.

File metadata

  • Download URL: djangodbu-0.0.17-py2-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.15

File hashes

Hashes for djangodbu-0.0.17-py2-none-any.whl
Algorithm Hash digest
SHA256 c55195dab2fde69a46d941561cc5d74dcda63442c7913db435d08a2d581f7d77
MD5 e928f370d7e5ec886441e120aad2d129
BLAKE2b-256 137e378bedddafd949464707d6b461d2fc31f1019658e0ed2f46802a72c1b460

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