django-cbv-inspect
A tool to help inspect all class-based views within your Django project 🔎 ✨
Inspired by django-debug-toolbar ❤️
📦 Installation
- Install with pip
pip install django-cbv-inspect
- Add
cbv_inspectto your list ofINSTALLED_APPSin your Django settings module
INSTALLED_APPS = [
...
"cbv_inspect",
...
]
- Add the middleware to your list of
MIDDLEWAREclasses in your Django settings module
MIDDLEWARE = [
...
"cbv_inspect.middleware.DjCbvInspectMiddleware",
...
]
-
Prerequisites
In your
TEMPLATESsettings within your Django settings module, make sure- the
BACKENDsetting is""django.template.backends.django.DjangoTemplates"" - the
APP_DIRSsetting isTrue
- the
🛞 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
from cbv_inspect.mixins import DjCbvExcludeMixin
class MyCoolView(DjCbvExcludeMixin, View):
pass
Exclude via decorator
from django.utils.decorators import method_decorator
from cbv_inspect.decorators import djcbv_exclude
@method_decorator(djcbv_exclude, name="dispatch")
class MyCoolView(View):
pass
🧪 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
⚡️ Features
The django-cbv-inspect toolbar has three main sections:
- View information
- CBV method call chain
- MRO classes
View information
This section shows high level information about the class-based view, request, and url.
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) links
- method arguments and return value
- all resolved
super()calls defined in the method - module location
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.
❓ 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 and 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! ✨
Metadata
Release files for django-cbv-inspect 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-cbv-inspect-0.2.1.tar.gz | 16.0 kB | Without provenance | Details for django-cbv-inspect-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_cbv_inspect-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for django_cbv_inspect-0.2.1-py3-none-any.whl |
Total release size: 31.5 kB
Release files / django-cbv-inspect-0.2.1.tar.gz
| Download URL | django-cbv-inspect-0.2.1.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e47af62ade912a5b097520c40e646d575f0e678f88ec12de65c3ce3244ce8e3
|
|
BLAKE2b-256 checksum How to use checksums |
fd0fd9b02bcf0947385029751d96f989a8b676e46998172896dccc8cb5e01aca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Release files / django_cbv_inspect-0.2.1-py3-none-any.whl
| Download URL | django_cbv_inspect-0.2.1-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64df0412987b0b385e3a07694839fe0dbbf473a413b5e6a4b1f62f54124de449
|
|
BLAKE2b-256 checksum How to use checksums |
12baebef0a442602a40a8d4c3e4570c6eb4c20ef1b0d67943a317bae4891fdd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Security for django-cbv-inspect 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.