Ashish Pitrodafield notes
All episodes

Wagtail Unboxed episode 10 4:05

Forms that work

A contact form the editor builds field by field, that emails the studio and stores every submission. And the three things Wagtail's defaults get wrong, every one measured.

What this episode covers

Submit it before writing a thank-you template and the visitor sees a 500 error, but the submission was saved and the email was sent. Refresh the thank-you page and it sends again. And an optional dropdown quietly records a choice nobody made.

What you'll learn

  • AbstractEmailForm and AbstractFormField: forms the editor builds
  • The form template, and the 403 you get without csrf_token
  • The 500 that already succeeded: the missing landing template
  • Why refreshing the thank-you page resubmits, and the Post/Redirect/Get fix
  • Why an optional dropdown has no blank choice, and a custom FormBuilder that adds one
  • A honeypot for spam, and why it must not be type="hidden"
  • Where the email goes in development
  • FormSubmissionsPanel: submissions and CSV export in the admin

Chapters

  1. 0:00 A studio you can't contact
  2. 0:20 Forms the editor builds
  3. 0:40 The template, and csrf_token
  4. 0:56 A 500 that already worked
  5. 1:11 Why the visitor sends it twice
  6. 1:31 Refresh sends it again
  7. 1:47 Post, redirect, get
  8. 2:08 The dropdown that lies
  9. 2:30 A custom FormBuilder
  10. 2:45 A honeypot for spam
  11. 3:14 Where the email goes
  12. 3:29 The contact form
  13. 3:39 The thank-you page
  14. 3:46 Commit and tag
  15. 3:50 Next episode

Versions on screen

Wagtail 7.4.3 · Django 6.1.1 · Python 3.12. Recorded on Windows; macOS and Linux commands are in the repository for every episode.

Next: episode 11, Search

Carry on from here.

Episode 11 or see all episodes