django_additional_tools
A collection of reusable Django utilities, middleware and app components.
Requirements
Python 3.10+
Django 4.2+ (or any newer LTS)
Works with WSGI and ASGI projects
Installation
pip install django_additional_tools
Features
Production‑only and development‑only decorators
Production/development template tags
Production/development boolean helpers
CSP nonce middleware
Configurable CSP settings
Production / Development Only
Imagine you are coding a new feature but don´t want it to be available for users yet. But you need to fix bugs etc. the same time so you have to push updates. This library solves this problem: There are different features that make specific code only available in production or development use, specified by django´s very own DEBUG setting.
INSTALLED_APPS += ['django_additional_tools']
Views
Use
from django_additional_tools.django_production_development_only.tags import production_only
@production_only
def my_view(request):
return render(request, 'my_template')
or
from django_additional_tools.django_production_development_only.tags import development_only
@development_only
def my_view(request):
return render(request, 'my_template')
to make a whole view only available in production or development mode.
Templates
Use
{% load production %}
{% if production %}
<h1>You´re in production mode</h1>
{% endif %}
or
{% load development %}
{% if development %}
<h1>You´re in development mode</h1>
{% endif %}
to make a whole view only available in production or development mode.
If-Clauses
Use
from django_additional_tools.django_production_development_only.ifs import production_only
def my_view(request):
if production_only:
print('You´re in production mode')
return render(request, 'my_template')
or
from django_additional_tools.django_production_development_only.ifs import development_only
def my_view(request):
if development_only:
print('You´re in development mode')
return render(request, 'my_template')
Content Security Policy
Add a content security policy to your website to secure it.
MIDDLEWARE += ['django_additional_tools.middleware.generate_csp_nonce_middleware']
# Add your configuration data here, e.g. the allowed script sources
# Your CSP will look like this
csp = (
"default-src 'self'; "
f"script-src 'self' 'nonce-{script_nonce}' {settings.CSP_ALLOWED_SCRIPT_DATA}; "
f"style-src 'self' 'nonce-{style_nonce}' {settings.CSP_ALLOWED_SCRIPT_DATA}; "
f"img-src 'self' {settings.CSP_ALLOWED_IMG_DATA}; "
f"frame-src {settings.CSP_ALLOWED_FRAME_DATA}; "
f"connect-src 'self' {settings.CSP_CONNECT_DATA}; "
f"media-src {settings.CSP_ALLOWED_MEDIA_DATA}"
)
# You can configure CSP_ALLOWED_SCRIPT_DATA etc. in the settings.
License
Copyright © 2026 Paul Hudelmaier
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.
Metadata
Release files for django-additional-tools 0.1.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_additional_tools-0.1.1.tar.gz | 8.1 kB | Without provenance | Details for django_additional_tools-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_additional_tools-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for django_additional_tools-0.1.1-py3-none-any.whl |
Total release size: 20.0 kB
Release files / django_additional_tools-0.1.1.tar.gz
| Download URL | django_additional_tools-0.1.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39dcaa7cdf9ae4a4d57abc81eb688ac1c364c2d5f15cc1dd8bc9a1939512c0ef
|
|
BLAKE2b-256 checksum How to use checksums |
bc215e40234a52abd602db6a7876f405d3c654ff65caa9cb324f921f5a24802e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / django_additional_tools-0.1.1-py3-none-any.whl
| Download URL | django_additional_tools-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f58d63e5cf6b81397484e18f3699602b34717b1ab8d98cf69558a8df4312683
|
|
BLAKE2b-256 checksum How to use checksums |
c3850ecd2225dcea380f10432b46e45e3031d7193de3cb7b00d99cdd2b78f22d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for django-additional-tools 0.1.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.