Django + Webhooks Made Easy
Project description
Django + Webhooks Made Easy
Warning: Still in pre-alpha status. Not used in production on ANYTHING.
Documentation
The full documentation is at https://dj-webhooks.readthedocs.org.
Requirements
django>=1.5.5
webhooks
django-jsonfield
Quickstart
Install dj-webhooks:
pip install dj-webhooks
Configure some webhook events:
# settings.py
WEBHOOK_EVENTS = (
"purchase.paid",
"purchase.refunded",
"purchase.fulfilled"
)
Add some webhook targets:
from django.contrib.auth import get_user_model
User = get_user_model()
user = User.objects.get(username="pydanny")
from webhooks.models import Webhook
WebhookTarget.objects.create(
owner=user,
event="purchase.confirmed",
target_url="https://mystorefront.com/webhooks/",
header_content_type=Webhook.CONTENT_TYPE_JSON,
)
Then use it in a project:
from django.contrib.auth import get_user_model
User = get_user_model()
user = User.objects.get(username="pydanny")
from djwebhooks.decorators import webhook
from myproject.models import Purchase
# Event argument helps identify the webhook target
@hook(event="purchase.paid")
def send_purchase_confirmation(purchase, webhook_owner):
# Webhook_owner also helps identify the webhook target
return {
"order_num": purchase.order_num,
"date": purchase.confirm_date,
"line_items": [x.sku for x in purchase.lineitem_set.filter(inventory__gt=0)]
}
for purchase in Purchase.objects.filter(status="paid"):
send_purchase_confirmation(purchase, user)
Requirements
Python 2.7.x or 3.3.2 or higher
Django 1.5 or higher
Features
Synchronous webhooks
Delivery tracking via Django ORM.
Planned Features
Options for asynchronous webhooks
Delivery tracking via Redis and other write-fast datastores.
History
0.1.0 (2014-05-12)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dj-webhooks-0.1.0.tar.gz
.
File metadata
- Download URL: dj-webhooks-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df2afb3e92767ca9d8be3c21563e18bbf126cff57dfe0005bc864ab45e08e458 |
|
MD5 | 11a40ea2518d6c2ef32e6862a4e59e33 |
|
BLAKE2b-256 | a9be8a791c660b4ff9ab0a74ad87f01c43666eea462631ed5f644d2f33bb0741 |
File details
Details for the file dj_webhooks-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: dj_webhooks-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bf891e41e7553c3e199fed6a89c09ee48afa3853b7d3f654c898aeb7476f24f |
|
MD5 | d3bdccc0ad144220e8bef779cff00d06 |
|
BLAKE2b-256 | bfc05936eb8f79c36bc2d2394ddd916b4090bb73dbd9ea2411ec0870ce283fd4 |