Django
Django forms and class-based views.
Keys required. Create a site in the dashboard and copy your site key (HTML) and secret key (server). Replace
sq_live_your_key in the snippets below.
How this integration works
Same three steps as every other platform — only the paste location and server hook change.
| Step | What you do for Django |
|---|---|
| 1 | Load squeaker.js once on pages with the form. |
| 2 | Widget in form template; load squeaker.js in base.html. |
| 3 | Verify squeaker-token on your server before saving or forwarding the submission. |
Where to put the widget
Widget in form template; load squeaker.js in base.html.
Recommended settings
| Setting | Value |
|---|---|
| Widget mode | Auto (recommended) — Runs on form submit — best for most forms |
| Form ID | #contact-form |
| Server verify | Python, Node.js |
Copy-paste snippet
Paste into your Django form or template. Load squeaker.js once per page.
<!-- Widget in form template; load squeaker.js in base.html. --> <squeaker-widget data-sitekey="sq_live_your_key" data-api="https://api.squeaker.cc/v1" data-mode="auto" data-theme="light" data-form="#contact-form" ></squeaker-widget> <!-- Load squeaker.js once per page --> <script src="https://cdn.squeaker.cc/squeaker.js" async defer></script> <!-- Verify squeaker-token on your server before processing the form -->
Server verification
Read squeaker-token from the request and POST to /v1/verify with your secret key.
Full reference: Server verify docs.
import json
import os
import urllib.request
token = request.form.get('squeaker-token')
if not token:
return {'error': 'Missing token'}, 400
api_url = os.environ.get('SQUEAKER_API_URL', 'https://api.squeaker.cc/v1')
payload = json.dumps({
'secret': os.environ['SQUEAKER_SECRET'],
'token': token,
'remoteip': request.remote_addr,
}).encode()
req = urllib.request.Request(
f'{api_url}/verify',
data=payload,
headers={'Content-Type': 'application/json'},
method='POST',
)
with urllib.request.urlopen(req) as resp:
result = json.loads(resp.read())
if not result.get('success'):
return {'error': result.get('error', 'Invalid token')}, 403
# Token valid — process the form Open setup generator with Django pre-selected · Browse all platforms