From 24d617074c021787e763e38df4703566707cce6d Mon Sep 17 00:00:00 2001 From: Erik Gaasedelen Date: Fri, 12 Dec 2025 13:11:50 -0800 Subject: [PATCH] Add note about Post/Redirect/Get pattern in by_example tutorial Explains that refreshing after POST can cause "resubmit form?" prompts, and that Redirect('/') is the traditional fix. Notes this isn't needed with HTMX since submissions happen via AJAX. Fixes #389 --- nbs/tutorials/by_example.ipynb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nbs/tutorials/by_example.ipynb b/nbs/tutorials/by_example.ipynb index 6853f1ee..64e19633 100644 --- a/nbs/tutorials/by_example.ipynb +++ b/nbs/tutorials/by_example.ipynb @@ -680,6 +680,14 @@ "We re-render the entire homepage to show the newly added message. This is fine, but modern web apps often don't re-render the entire page, they just update a part of the page. In fact even very complicated applications are often implemented as 'Single Page Apps' (SPAs). This is where HTMX comes in." ] }, + { + "cell_type": "markdown", + "id": "prg-note", + "metadata": {}, + "source": [ + "> **Note:** With traditional form submissions, refreshing the page after a POST will prompt \\\"Resubmit form data?\\\" — potentially causing duplicate entries. The standard fix is `return Redirect('/')` instead of `return home()`, known as the [Post/Redirect/Get](https://en.wikipedia.org/wiki/Post/Redirect/Get) pattern. With HTMX (covered next), this isn't needed since submissions happen via AJAX." + ] + }, { "cell_type": "markdown", "id": "0e7066db",