django-dump-die


Namedjango-dump-die JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/DJBarnes/django-dump-die
SummaryA Django app to add Laravel/Symfony-like dump and die functionality.
upload_time2023-09-17 20:58:36
maintainer
docs_urlNone
authorDavid Barnes, Brandon Rodriguez
requires_python>=3.8
licenseMIT License Copyright (c) 2023 David Barnes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords debug dd die django dump inspect tool
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            Django Dump & Die
============================

[![PyPI](https://img.shields.io/pypi/v/django-dump-die?color=blue)](https://img.shields.io/pypi/v/django-dump-die?color=blue)
[![Python Versions](https://img.shields.io/badge/python-%3E%3D3.8-brightgreen)](https://img.shields.io/badge/python-%3E%3D3.8-brightgreen)
[![Django Versions](https://img.shields.io/badge/django-%3E%3D3.2-brightgreen)](https://img.shields.io/badge/django-%3E%3D3.2-brightgreen)
[![Documentation Status](https://readthedocs.org/projects/django-dump-die/badge/?version=latest)](https://django-dump-die.readthedocs.io/en/latest/?badge=latest)
[![PyPI Downloads per Month](https://img.shields.io/pypi/dm/django-dump-die.svg)](https://pypi.python.org/pypi/django-dump-die)
[![GitHub](https://img.shields.io/github/license/DJBarnes/django-dump-die)](https://img.shields.io/github/license/DJBarnes/django-dump-die)


Django-Dump-Die is a [Django](https://www.djangoproject.com/) app that
provides a couple of debug tools, in the form of built-in methods
`dump` and `dd`. These allow sending details about a variable to the
browser for inspection.

Dumped variables are presented in an easy to read and
fully expandable / collapsible tree. You can easily understand complex objects
and the results of django queries with a simple call to either method.

When `dump` and/or `dd` are called, dump die will intercept the page
response and replace the contents of the response with detailed information
about the corresponding variables passed for inspection.

The entire concept is heavily based on the dump die functionality that comes
with Php's [Laravel](https://laravel.com/)
and [Symfony](https://symfony.com/) frameworks.

Full documentation on [ReadTheDocs](https://django-dump-die.readthedocs.io/en/latest/).

![dd_sample_output](https://user-images.githubusercontent.com/4390026/173413467-afcea349-a28b-42c0-bd18-5922df17b453.png)

## Quickstart
1.  Install the Django App via Pypi.
    ```shell
    python -m pip install django-dump-die
    ```

<br>

2.  Add the corresponding app to your Django ``settings.py`` file:
    ```python
    INSTALLED_APPS = [

        'django_dump_die',
        ...
    ]
    ```

<br>

3.  Add the corresponding middleware to your Django ``settings.py`` file:
    ```python
    MIDDLEWARE = [

        'django_dump_die.middleware.DumpAndDieMiddleware',
        ...
    ]
    ```

4.  Ensure that you have **DEBUG** set to ``True`` in your Django ``settings.py`` file:
    ```python
    DEBUG = True
    ```

    ---
    :information_source: **NOTE**
    Neither the `dump` command nor the `dd` command will do anything if **DEBUG** is not set to `True`.
    With that said, this is a tool for debugging. You should not include this package
    in production nor should you ever have **DEBUG** set to `True` in production.

    ---

5.  From a file that is part of the request / response cycle such as a Django
    View in `views.py`, make a call to dd sending it the contents of a variable
    to inspect.

    **views.py**
    ```python
    def my_awesome_view(request):
        dd(request)
    ```

## Usage
The middleware is where most of this package's heavy lifting happens.

By having the middleware installed, you can run ``dump(<variable>)`` and/or
``dd(<variable>)`` in any file that is part of the request response cycle,
and it will run the dump logic. No importing or extra logic is required.

Each ``dump(<variable>)`` command will add the passed object to an internal
list that will be dumped either when a ``dd(<variable>)`` is used, or if the
entirety of the request finishes. You can have as many ``dump(<variable>)``
statements as you want leading up to an optional ``dd(<variable>)``.

If you make a call to ``dd(<variable>)``, execution will immediately stop
and all dumped objects (including the the one sent to dd) will be output.

If you do not make a call to ``dd(<variable>)`` and only use
``dump(<variable>)`` statements, the request will continue processing until
it is time to return the response. At this point, Django-Dump-Die will
intercept and replace the response with the data that has been dumped thus
far.

---
:information_source: **NOTE**
Because dump die uses middleware to internally handle keeping track of
what to dump and then actually dumping the data to the browser, any
call to ``dump`` or ``dd`` must be done in a file that will be processed
during the request response cycle. Most commonly this will be a
``views.py`` file, but could also be utils called from a view.
Attempting to ``dump`` or ``dd`` from a console command will not work.

---

<br>

Example:
```python
# Sample classes for output.
class EmptyClass:
    """Empty Class."""
    pass


class SomeClass:
    """Some Class."""
    SAMPLE_CONST = 41

    def __init__(self, *args, **kwargs):
        self.my_number = 32
        self.my_string = 'A super cool string'
        self.works = True
        self.nothing = None
        self.bytes = bytes('My Bytes', 'utf-8')
        self.list_o_stuff = ['A', 'B', 'C']
        self.sample_set = {'A', 'B', 'C'}
        self.sample_tuple = ('A', 12, True)
        self.empty_class = EmptyClass()
        self.empty_class_dup = self.empty_class

    def do_work(self):
        """Do some work"""
        return True


# Example Usage
empty_class = EmptyClass()
some_class = SomeClass()

dump('Simple String')
dump(empty_class)
dd(some_class)
```
![django-dump-die-sample-output](https://user-images.githubusercontent.com/4390026/159033583-b2d4d98e-52c1-487e-93a3-5c56e7038893.png)

<br>

---
:information_source: **NOTE**
Most editors will give a red error squiggle for the dd command.
This is intentional, and the command will still run. This is because this
command is meant to be used for debugging, and is not meant to stay
long-term. The red squiggle helps identify it as something that should be
removed before any actual commits.

---

### Usage & Parameters
For further documentation on usage and parameters, see
[ReadTheDocs/Usage](https://django-dump-die.readthedocs.io/en/latest/usage.html)


## Configuration
The package has a few available configuration options and settings, which are
documented at
[ReadTheDocs/Configuration](https://django-dump-die.readthedocs.io/en/latest/configuration.html)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/DJBarnes/django-dump-die",
    "name": "django-dump-die",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "David Barnes <barnesdavidj@gmail.com>, Brandon Rodriguez <brodriguez8774@gmail.com>",
    "keywords": "debug,dd,die,django,dump,inspect,tool",
    "author": "David Barnes, Brandon Rodriguez",
    "author_email": "David Barnes <barnesdavidj@gmail.com>, Brandon Rodriguez <brodriguez8774@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b1/1c/e7e2bb72797835aca5e5d42d483336c89d5c36674880356528e1d4313849/django-dump-die-0.1.7.tar.gz",
    "platform": null,
    "description": "Django Dump & Die\n============================\n\n[![PyPI](https://img.shields.io/pypi/v/django-dump-die?color=blue)](https://img.shields.io/pypi/v/django-dump-die?color=blue)\n[![Python Versions](https://img.shields.io/badge/python-%3E%3D3.8-brightgreen)](https://img.shields.io/badge/python-%3E%3D3.8-brightgreen)\n[![Django Versions](https://img.shields.io/badge/django-%3E%3D3.2-brightgreen)](https://img.shields.io/badge/django-%3E%3D3.2-brightgreen)\n[![Documentation Status](https://readthedocs.org/projects/django-dump-die/badge/?version=latest)](https://django-dump-die.readthedocs.io/en/latest/?badge=latest)\n[![PyPI Downloads per Month](https://img.shields.io/pypi/dm/django-dump-die.svg)](https://pypi.python.org/pypi/django-dump-die)\n[![GitHub](https://img.shields.io/github/license/DJBarnes/django-dump-die)](https://img.shields.io/github/license/DJBarnes/django-dump-die)\n\n\nDjango-Dump-Die is a [Django](https://www.djangoproject.com/) app that\nprovides a couple of debug tools, in the form of built-in methods\n`dump` and `dd`. These allow sending details about a variable to the\nbrowser for inspection.\n\nDumped variables are presented in an easy to read and\nfully expandable / collapsible tree. You can easily understand complex objects\nand the results of django queries with a simple call to either method.\n\nWhen `dump` and/or `dd` are called, dump die will intercept the page\nresponse and replace the contents of the response with detailed information\nabout the corresponding variables passed for inspection.\n\nThe entire concept is heavily based on the dump die functionality that comes\nwith Php's [Laravel](https://laravel.com/)\nand [Symfony](https://symfony.com/) frameworks.\n\nFull documentation on [ReadTheDocs](https://django-dump-die.readthedocs.io/en/latest/).\n\n![dd_sample_output](https://user-images.githubusercontent.com/4390026/173413467-afcea349-a28b-42c0-bd18-5922df17b453.png)\n\n## Quickstart\n1.  Install the Django App via Pypi.\n    ```shell\n    python -m pip install django-dump-die\n    ```\n\n<br>\n\n2.  Add the corresponding app to your Django ``settings.py`` file:\n    ```python\n    INSTALLED_APPS = [\n\n        'django_dump_die',\n        ...\n    ]\n    ```\n\n<br>\n\n3.  Add the corresponding middleware to your Django ``settings.py`` file:\n    ```python\n    MIDDLEWARE = [\n\n        'django_dump_die.middleware.DumpAndDieMiddleware',\n        ...\n    ]\n    ```\n\n4.  Ensure that you have **DEBUG** set to ``True`` in your Django ``settings.py`` file:\n    ```python\n    DEBUG = True\n    ```\n\n    ---\n    :information_source: **NOTE**\n    Neither the `dump` command nor the `dd` command will do anything if **DEBUG** is not set to `True`.\n    With that said, this is a tool for debugging. You should not include this package\n    in production nor should you ever have **DEBUG** set to `True` in production.\n\n    ---\n\n5.  From a file that is part of the request / response cycle such as a Django\n    View in `views.py`, make a call to dd sending it the contents of a variable\n    to inspect.\n\n    **views.py**\n    ```python\n    def my_awesome_view(request):\n        dd(request)\n    ```\n\n## Usage\nThe middleware is where most of this package's heavy lifting happens.\n\nBy having the middleware installed, you can run ``dump(<variable>)`` and/or\n``dd(<variable>)`` in any file that is part of the request response cycle,\nand it will run the dump logic. No importing or extra logic is required.\n\nEach ``dump(<variable>)`` command will add the passed object to an internal\nlist that will be dumped either when a ``dd(<variable>)`` is used, or if the\nentirety of the request finishes. You can have as many ``dump(<variable>)``\nstatements as you want leading up to an optional ``dd(<variable>)``.\n\nIf you make a call to ``dd(<variable>)``, execution will immediately stop\nand all dumped objects (including the the one sent to dd) will be output.\n\nIf you do not make a call to ``dd(<variable>)`` and only use\n``dump(<variable>)`` statements, the request will continue processing until\nit is time to return the response. At this point, Django-Dump-Die will\nintercept and replace the response with the data that has been dumped thus\nfar.\n\n---\n:information_source: **NOTE**\nBecause dump die uses middleware to internally handle keeping track of\nwhat to dump and then actually dumping the data to the browser, any\ncall to ``dump`` or ``dd`` must be done in a file that will be processed\nduring the request response cycle. Most commonly this will be a\n``views.py`` file, but could also be utils called from a view.\nAttempting to ``dump`` or ``dd`` from a console command will not work.\n\n---\n\n<br>\n\nExample:\n```python\n# Sample classes for output.\nclass EmptyClass:\n    \"\"\"Empty Class.\"\"\"\n    pass\n\n\nclass SomeClass:\n    \"\"\"Some Class.\"\"\"\n    SAMPLE_CONST = 41\n\n    def __init__(self, *args, **kwargs):\n        self.my_number = 32\n        self.my_string = 'A super cool string'\n        self.works = True\n        self.nothing = None\n        self.bytes = bytes('My Bytes', 'utf-8')\n        self.list_o_stuff = ['A', 'B', 'C']\n        self.sample_set = {'A', 'B', 'C'}\n        self.sample_tuple = ('A', 12, True)\n        self.empty_class = EmptyClass()\n        self.empty_class_dup = self.empty_class\n\n    def do_work(self):\n        \"\"\"Do some work\"\"\"\n        return True\n\n\n# Example Usage\nempty_class = EmptyClass()\nsome_class = SomeClass()\n\ndump('Simple String')\ndump(empty_class)\ndd(some_class)\n```\n![django-dump-die-sample-output](https://user-images.githubusercontent.com/4390026/159033583-b2d4d98e-52c1-487e-93a3-5c56e7038893.png)\n\n<br>\n\n---\n:information_source: **NOTE**\nMost editors will give a red error squiggle for the dd command.\nThis is intentional, and the command will still run. This is because this\ncommand is meant to be used for debugging, and is not meant to stay\nlong-term. The red squiggle helps identify it as something that should be\nremoved before any actual commits.\n\n---\n\n### Usage & Parameters\nFor further documentation on usage and parameters, see\n[ReadTheDocs/Usage](https://django-dump-die.readthedocs.io/en/latest/usage.html)\n\n\n## Configuration\nThe package has a few available configuration options and settings, which are\ndocumented at\n[ReadTheDocs/Configuration](https://django-dump-die.readthedocs.io/en/latest/configuration.html)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 David Barnes  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A Django app to add Laravel/Symfony-like dump and die functionality.",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/djbarnes/django-dump-die"
    },
    "split_keywords": [
        "debug",
        "dd",
        "die",
        "django",
        "dump",
        "inspect",
        "tool"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f102a8e955decba15ae7ca5169dc3e9a1fd9eea20ed7c768e37196be9da632e",
                "md5": "fdf45517af3d367ed30c73f532a8ce90",
                "sha256": "37f5c62d9b1d950ed8fdb17d420b78b90f54f8a4aabe93b973f5b7daa3e6892e"
            },
            "downloads": -1,
            "filename": "django_dump_die-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fdf45517af3d367ed30c73f532a8ce90",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 68507,
            "upload_time": "2023-09-17T20:58:34",
            "upload_time_iso_8601": "2023-09-17T20:58:34.692019Z",
            "url": "https://files.pythonhosted.org/packages/3f/10/2a8e955decba15ae7ca5169dc3e9a1fd9eea20ed7c768e37196be9da632e/django_dump_die-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b11ce7e2bb72797835aca5e5d42d483336c89d5c36674880356528e1d4313849",
                "md5": "33684cf0774e372d4c4cb00d0b872830",
                "sha256": "48468d6618346cbf5ff56de58b491695427eb8d0e9545db5a95465a0be74301a"
            },
            "downloads": -1,
            "filename": "django-dump-die-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "33684cf0774e372d4c4cb00d0b872830",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 57582,
            "upload_time": "2023-09-17T20:58:36",
            "upload_time_iso_8601": "2023-09-17T20:58:36.708984Z",
            "url": "https://files.pythonhosted.org/packages/b1/1c/e7e2bb72797835aca5e5d42d483336c89d5c36674880356528e1d4313849/django-dump-die-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-17 20:58:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DJBarnes",
    "github_project": "django-dump-die",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "lcname": "django-dump-die"
}
        
Elapsed time: 0.11738s