Using Web2Phone with Django Templates
Use Web2Phone inside plain Django templates with the standard embed snippet — no Django views, no models, no backend form handling.
If you haven’t created a form yet, start with the Getting Started guide.
How delivery works
Web2Phone delivers to WhatsApp if enabled and delivery succeeds. If WhatsApp is disabled (or delivery fails), it falls back to email. Failed deliveries appear in your dashboard as queued or failed. Successful submissions are not shown.
Create a Web2Phone Form
- Create a form in the Web2Phone dashboard.
-
Under Allowed Domains, add your site’s hostname
(for example
example.com,www.example.com,localhost). - Save the form and copy the embed snippet.
Allowed Domains rules
Web2Phone checks the hostname the form is submitted from. Protocols, paths, and query strings are ignored.
- ✅ Enter the hostname only (e.g.
example.com) - ✅
example.comandwww.example.comare treated as equivalent - ❌ No
http://orhttps:// - ❌ No paths (like
/contact) - ❌ No wildcards (like
*.example.com)
Paste the Snippet into a Template
Open the template where you want the form (for example contact.html)
and paste the snippet exactly as provided.
<form data-web2phone="form" data-public-key="YOUR_PUBLIC_KEY" data-endpoint="https://web2phone.co.uk/api/v1/submit/"> <input name="name" placeholder="Your name" required> <input name="email" type="email" placeholder="[email protected]" required> <textarea name="message" placeholder="Message" required></textarea> <button type="submit">Send</button> <p data-w2p-output></p> </form> <script src="https://web2phone.co.uk/static/formsapp/js/embed.js"></script>
Always copy the snippet from your dashboard so the public key is correct.
Do not add Django CSRF to this form
This form posts directly to Web2Phone, not your Django backend.
You do not need {{ csrf_token }}.
Test and Verify Delivery
- Load your page in a browser.
- Submit a test message.
- Expect WhatsApp or email delivery based on your form settings.
If it doesn’t work
- Confirm the hostname in Allowed Domains matches your site (
wwwis optional). - Check you used the snippet from the correct form.
- Look in the dashboard for queued or failed submissions.