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).
- 🚀 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
pip install django-webmonetization-MartinM10- 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',
]{% 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>The middleware automatically adds the Web-Monetization-Pointer header to all HTTP responses. You can verify it with curl:
curl -I https://your-site.comYou should see something like:
HTTP/1.1 200 OK
...
Web-Monetization-Pointer: $ilp.example.com/your-payment-pointer
# 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>- Python 3.7+
- Django 3.2+
- pytest>=7.0.0
- pytest-cov>=4.0.0
Contributions are welcome! Please feel free to submit a pull request.
MIT License - see the LICENSE file for details.