django-cbv-inspect


Namedjango-cbv-inspect JSON
Version 0.2.1 PyPI version JSON
download
home_page
SummaryA tool to inspect Django class-based views.
upload_time2023-01-02 08:25:37
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT
keywords python django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
    django-cbv-inspect
</h1>

<div align="center">
<a href="https://pypi.org/project/django-cbv-inspect/">
    <img src="https://img.shields.io/pypi/v/django-cbv-inspect?color=blue" alt="PyPI"/>
</a>
<a href="https://github.com/sjbitcode/django-cbv-inspect/actions/workflows/test.yml">
    <img src="https://github.com/sjbitcode/django-cbv-inspect/actions/workflows/test.yml/badge.svg?branch=master&event=push" alt="Test">
</a>
<a href="https://codecov.io/gh/sjbitcode/django-cbv-inspect" > 
    <img src="https://codecov.io/gh/sjbitcode/django-cbv-inspect/branch/master/graph/badge.svg?token=wAjvQLGtpd"/> 
</a>
<a href="https://pypi.org/project/django-cbv-inspect/">
    <img src="https://img.shields.io/pypi/pyversions/django-cbv-inspect" alt="python-versions">
</a>
<a href="https://pypi.org/project/django-cbv-inspect/">
    <img src="https://img.shields.io/pypi/frameworkversions/django/django-cbv-inspect.svg" alt="django-versions">
</a>
</div>

<br>

<div align="center">
    <p>A tool to help inspect all class-based views within your Django project ๐Ÿ”Ž โœจ </p>
    Inspired by django-debug-toolbar โค๏ธ
</div>

<p align="center">
    <br>
    <img src="https://user-images.githubusercontent.com/6550256/210189547-b173d5a6-d69f-482e-b85b-5be31098610c.gif" alt="django-cbv-inspect demo"/>
</p>

<br>

---

<br>

## ๐Ÿ“ฆ Installation
1. Install with pip
```
pip install django-cbv-inspect
```

2. Add `cbv_inspect` to your list of `INSTALLED_APPS` in your Django settings module
```python
INSTALLED_APPS = [
    ...
    "cbv_inspect",
    ...
]
```

3. Add the middleware to your list of `MIDDLEWARE` classes in your Django settings module
```python
MIDDLEWARE = [
    ...
    "cbv_inspect.middleware.DjCbvInspectMiddleware",
    ...
]
```

4. **Prerequisites**
    
    In your `TEMPLATES` settings within your Django settings module, make sure
   1. the `BACKEND` setting is `""django.template.backends.django.DjangoTemplates""`
   2. the `APP_DIRS` setting is `True`

<br>

---

<br>

## ๐Ÿ›ž Usage
When all installation steps are done, any html response rendered by a class-based view should display the `django-cbv-inspect` toolbar on the page.

By default, all class-based views will be processed by the middleware. If you wish to exclude views, there are two options:

### Exclude via mixin
```python
from cbv_inspect.mixins import DjCbvExcludeMixin


class MyCoolView(DjCbvExcludeMixin, View):
    pass
```


### Exclude via decorator
```python
from django.utils.decorators import method_decorator
from cbv_inspect.decorators import djcbv_exclude


@method_decorator(djcbv_exclude, name="dispatch")
class MyCoolView(View):
    pass
```

<br>

---

<br>

## ๐Ÿงช Run locally
You can run the `example` project locally to test things out!

Clone the project and from the root of the repo, run the following Make command to setup the `example` project:
```
make run-example
```

To run unittests with coverage, run
```
make coverage
```

<br>

---

<br>

## โšก๏ธ Features

The `django-cbv-inspect` toolbar has three main sections:

1. View information
2. CBV method call chain
3. MRO classes

<br>

### View information

This section shows high level information about the class-based view, request, and url.

<br>

### CBV method call chain

This is the main section that shows all methods that were excuted for the current class-based view:

It shows:
- method name and signature
- [Classy Class-Based Views (ccbv.co.uk)](https://ccbv.co.uk/) links
- method arguments and return value
- all resolved `super()` calls defined in the method
- module location


<br>

### MRO classes
This section lists all MRO classes of the current class-based view class. 

This can come in handy especially with the prior section when mapping the execution of a class-based view.

<br>

---

<br>

## โ“ Why did I build this?

Django class-based views are hard to grasp especially when you're new to Django.

Fortunately for us, tools like [django-debug-toolbar](https://github.com/jazzband/django-debug-toolbar) and [ccbv.co.uk](https://ccbv.co.uk/) are super helpful in providing extra context for debugging.

My goal for this app was to take what goes on under the hood in a class-based view and display it in an easy to use interface, just like what django-debug-toolbar does.

Hopefully this can help debug your class-based views!

Happy coding! โœจ

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-cbv-inspect",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "python,django",
    "author": "",
    "author_email": "Sangeeta Jadoonanan <sjbitcode@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fd/0f/d9b02bcf0947385029751d96f989a8b676e46998172896dccc8cb5e01aca/django-cbv-inspect-0.2.1.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n    django-cbv-inspect\n</h1>\n\n<div align=\"center\">\n<a href=\"https://pypi.org/project/django-cbv-inspect/\">\n    <img src=\"https://img.shields.io/pypi/v/django-cbv-inspect?color=blue\" alt=\"PyPI\"/>\n</a>\n<a href=\"https://github.com/sjbitcode/django-cbv-inspect/actions/workflows/test.yml\">\n    <img src=\"https://github.com/sjbitcode/django-cbv-inspect/actions/workflows/test.yml/badge.svg?branch=master&event=push\" alt=\"Test\">\n</a>\n<a href=\"https://codecov.io/gh/sjbitcode/django-cbv-inspect\" > \n    <img src=\"https://codecov.io/gh/sjbitcode/django-cbv-inspect/branch/master/graph/badge.svg?token=wAjvQLGtpd\"/> \n</a>\n<a href=\"https://pypi.org/project/django-cbv-inspect/\">\n    <img src=\"https://img.shields.io/pypi/pyversions/django-cbv-inspect\" alt=\"python-versions\">\n</a>\n<a href=\"https://pypi.org/project/django-cbv-inspect/\">\n    <img src=\"https://img.shields.io/pypi/frameworkversions/django/django-cbv-inspect.svg\" alt=\"django-versions\">\n</a>\n</div>\n\n<br>\n\n<div align=\"center\">\n    <p>A tool to help inspect all class-based views within your Django project \ud83d\udd0e \u2728 </p>\n    Inspired by django-debug-toolbar \u2764\ufe0f\n</div>\n\n<p align=\"center\">\n    <br>\n    <img src=\"https://user-images.githubusercontent.com/6550256/210189547-b173d5a6-d69f-482e-b85b-5be31098610c.gif\" alt=\"django-cbv-inspect demo\"/>\n</p>\n\n<br>\n\n---\n\n<br>\n\n## \ud83d\udce6 Installation\n1. Install with pip\n```\npip install django-cbv-inspect\n```\n\n2. Add `cbv_inspect` to your list of `INSTALLED_APPS` in your Django settings module\n```python\nINSTALLED_APPS = [\n    ...\n    \"cbv_inspect\",\n    ...\n]\n```\n\n3. Add the middleware to your list of `MIDDLEWARE` classes in your Django settings module\n```python\nMIDDLEWARE = [\n    ...\n    \"cbv_inspect.middleware.DjCbvInspectMiddleware\",\n    ...\n]\n```\n\n4. **Prerequisites**\n    \n    In your `TEMPLATES` settings within your Django settings module, make sure\n   1. the `BACKEND` setting is `\"\"django.template.backends.django.DjangoTemplates\"\"`\n   2. the `APP_DIRS` setting is `True`\n\n<br>\n\n---\n\n<br>\n\n## \ud83d\udede Usage\nWhen all installation steps are done, any html response rendered by a class-based view should display the `django-cbv-inspect` toolbar on the page.\n\nBy default, all class-based views will be processed by the middleware. If you wish to exclude views, there are two options:\n\n### Exclude via mixin\n```python\nfrom cbv_inspect.mixins import DjCbvExcludeMixin\n\n\nclass MyCoolView(DjCbvExcludeMixin, View):\n    pass\n```\n\n\n### Exclude via decorator\n```python\nfrom django.utils.decorators import method_decorator\nfrom cbv_inspect.decorators import djcbv_exclude\n\n\n@method_decorator(djcbv_exclude, name=\"dispatch\")\nclass MyCoolView(View):\n    pass\n```\n\n<br>\n\n---\n\n<br>\n\n## \ud83e\uddea Run locally\nYou can run the `example` project locally to test things out!\n\nClone the project and from the root of the repo, run the following Make command to setup the `example` project:\n```\nmake run-example\n```\n\nTo run unittests with coverage, run\n```\nmake coverage\n```\n\n<br>\n\n---\n\n<br>\n\n## \u26a1\ufe0f Features\n\nThe `django-cbv-inspect` toolbar has three main sections:\n\n1. View information\n2. CBV method call chain\n3. MRO classes\n\n<br>\n\n### View information\n\nThis section shows high level information about the class-based view, request, and url.\n\n<br>\n\n### CBV method call chain\n\nThis is the main section that shows all methods that were excuted for the current class-based view:\n\nIt shows:\n- method name and signature\n- [Classy Class-Based Views (ccbv.co.uk)](https://ccbv.co.uk/) links\n- method arguments and return value\n- all resolved `super()` calls defined in the method\n- module location\n\n\n<br>\n\n### MRO classes\nThis section lists all MRO classes of the current class-based view class. \n\nThis can come in handy especially with the prior section when mapping the execution of a class-based view.\n\n<br>\n\n---\n\n<br>\n\n## \u2753 Why did I build this?\n\nDjango class-based views are hard to grasp especially when you're new to Django.\n\nFortunately for us, tools like [django-debug-toolbar](https://github.com/jazzband/django-debug-toolbar) and [ccbv.co.uk](https://ccbv.co.uk/) are super helpful in providing extra context for debugging.\n\nMy goal for this app was to take what goes on under the hood in a class-based view and display it in an easy to use interface, just like what django-debug-toolbar does.\n\nHopefully this can help debug your class-based views!\n\nHappy coding! \u2728\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A tool to inspect Django class-based views.",
    "version": "0.2.1",
    "split_keywords": [
        "python",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "c0c71c2051614fcde9d30ff0159b71ec",
                "sha256": "64df0412987b0b385e3a07694839fe0dbbf473a413b5e6a4b1f62f54124de449"
            },
            "downloads": -1,
            "filename": "django_cbv_inspect-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c0c71c2051614fcde9d30ff0159b71ec",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 15530,
            "upload_time": "2023-01-02T08:25:36",
            "upload_time_iso_8601": "2023-01-02T08:25:36.217647Z",
            "url": "https://files.pythonhosted.org/packages/12/ba/ebef0a442602a40a8d4c3e4570c6eb4c20ef1b0d67943a317bae4891fdd3/django_cbv_inspect-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "54947b4534796e62aef106b43e910f96",
                "sha256": "9e47af62ade912a5b097520c40e646d575f0e678f88ec12de65c3ce3244ce8e3"
            },
            "downloads": -1,
            "filename": "django-cbv-inspect-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "54947b4534796e62aef106b43e910f96",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 15988,
            "upload_time": "2023-01-02T08:25:37",
            "upload_time_iso_8601": "2023-01-02T08:25:37.915468Z",
            "url": "https://files.pythonhosted.org/packages/fd/0f/d9b02bcf0947385029751d96f989a8b676e46998172896dccc8cb5e01aca/django-cbv-inspect-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-02 08:25:37",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "django-cbv-inspect"
}
        
Elapsed time: 0.02644s