django-check-html-middleware
This middleware for the Django Web Frameworks checks the HTML you create.
The middleware should only be used during development.
By default the middleware deactivates itself, if settings.DEBUG is False.
In Action
Imagine you have a typo in your HTML like this: <th>foo</td>, then you get a html page like this:
line 89, col 14: discarding unexpected </td>:
<th>foo</td>
Anachronism?
Many people send JSON instead of HTML over the wire these days....
I use htmx and function-based-views if I can choose :-)
Install
pip install django-check-html-middleware
settings.py
Add check_html.CheckHTMLMiddleware at the start of your middleware.
If you use the Django-Debug-Toolbar, then put the check-html middleware below it.
MIDDLEWARE = [
'check_html.CheckHTMLMiddleware',
....
]
CHECK_HTML_IGNORE_MESSAGES: A list of strings. Each string is an error messages which should get ignored.
Defaults to:
[
'trimming empty',
'proprietary attribute',
'missing <!DOCTYPE> declaration',
'inserting implicit <body>',
'''inserting missing 'title' element''',
'moved <style> tag to <head>',
'inserting implicit <p>',
]
CHECK_HTML_IGNORE_REGEX_PATH: A list of regex strings. If a URL path matches this string, this response does not get checked.
Defaults to:
[
'/admin/.*',
]
Wrapper for "utidylib"
This middleware is just a thin wrapper for utidylib.
Feedback is welcome!
What do you think could get improved?
Please tell me and open an issue at github.
Thank you!
Development installation
python3 -m venv check-html-env
cd check-html-env/
. bin/activate
pip install -U pip wheel
git clone git@github.com:guettli/django-check-html-middleware.git
mv django-check-html-middleware code
pip install -e code
cd code
pytest
Metadata
Release files for django-check-html-middleware 2021.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_check_html_middleware-2021.10.1-py3-none-any.whl | Python 3 | none | any | Details for django_check_html_middleware-2021.10.1-py3-none-any.whl |
Release files / django_check_html_middleware-2021.10.1-py3-none-any.whl
| Download URL | django_check_html_middleware-2021.10.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eef07498900d2d81b405f43bbe54ef90159beb8cafae4237f04298ab69fc1690
|
|
BLAKE2b-256 checksum How to use checksums |
f350a09ba97b2ee282b7181c99d59003b70ee210357ba81be8b4ffd09e08597a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10
|
Security for django-check-html-middleware 2021.10.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.