Django Web Monetization
A Django package that makes it easy to integrate the Web Monetization specification into web applications. It enables developers to monetize their websites through real-time payments using the Interledger Protocol (ILP).
Features
- 🚀 Middleware to automatically add the payment pointer to HTTP headers
- 🎯 Template tag to insert the monetization meta tag in templates
- ⚙️ Simple configuration through settings.py
- 🔒 Compatible with Django 3.2+
- 📦 Easy installation with pip
Resources
Installation
pip install django-webmonetization-MartinM10
Configuration
- Add 'django_webmonetization' to INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
...
'django_webmonetization',
]
- Configure your payment pointer in settings.py:
WEBMONETIZATION_PAYMENT_POINTER = '$ilp.example.com/your-payment-pointer'
- (Optional) Add the middleware to MIDDLEWARE in settings.py:
MIDDLEWARE = [
...
'django_webmonetization.middleware.WebMonetizationMiddleware',
]
Usage
In Django Templates
{% load webmonetization %}
<!DOCTYPE html>
<html>
<head>
{% webmonetization_meta %}
<title>My Monetized Website</title>
</head>
<body>
<h1>Welcome to my website</h1>
<p>This site is monetized with Web Monetization</p>
</body>
</html>
HTTP Headers Verification
The middleware automatically adds the Web-Monetization-Pointer header to all HTTP responses. You can verify it with curl:
curl -I https://your-site.com
You should see something like:
HTTP/1.1 200 OK
...
Web-Monetization-Pointer: $ilp.example.com/your-payment-pointer
Integration Examples
1. Basic Monetization
# settings.py
WEBMONETIZATION_PAYMENT_POINTER = '$ilp.example.com/basic'
# views.py
from django.shortcuts import render
def home(request):
return render(request, 'home.html')
<!-- templates/home.html -->
{% load webmonetization %}
<!DOCTYPE html>
<html>
<head>
{% webmonetization_meta %}
</head>
<body>
<h1>Home Page</h1>
</body>
</html>
Requirements
Main Dependencies
- Python 3.7+
- Django 3.2+
Development Dependencies
- pytest>=7.0.0
- pytest-cov>=4.0.0
Contributing
Contributions are welcome! Please feel free to submit a pull request.
License
MIT License - see the LICENSE file for details.
Metadata
Release files for django-webmonetization-MartinM10 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_webmonetization_martinm10-0.1.3.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_webmonetization_martinm10-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.0 kB
Release files / django_webmonetization_martinm10-0.1.3.tar.gz
| Download URL | django_webmonetization_martinm10-0.1.3.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0be4fdd8964b834e0f0cc06aec33aeb6dac2ad8a4697941a4b523ab03d8fddbd
|
|
BLAKE2b-256 checksum How to use checksums |
3107d26cdbbee391a18f9e181e45eace51ed951ad82fa37f086a612048827d22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / django_webmonetization_martinm10-0.1.3-py3-none-any.whl
| Download URL | django_webmonetization_martinm10-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce29fce282f954fce08eb67e889cad0a455dbf5e7c92bbe18f12fb1f04a8ccc4
|
|
BLAKE2b-256 checksum How to use checksums |
e712f68227d44b6326ea5e0790bcde871caeb3d500f83abe157b455072a76e56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|