fix: resolve bulk upload Turbo error with PRG pattern#377
Open
mnietona wants to merge 1 commit intoDocHub-ULB:mainfrom
Open
fix: resolve bulk upload Turbo error with PRG pattern#377mnietona wants to merge 1 commit intoDocHub-ULB:mainfrom
mnietona wants to merge 1 commit intoDocHub-ULB:mainfrom
Conversation
This was referenced Mar 29, 2026
| "course": course, | ||
| }, | ||
| success_url = ( | ||
| reverse("document_submit_bulk", args=[course.slug]) + "?success=1" |
Contributor
There was a problem hiding this comment.
Please use the query parameter of reverse instead of crafting the url by hand: https://docs.djangoproject.com/en/6.0/ref/urlresolvers/#reverse
Contributor
There was a problem hiding this comment.
Also, could you try to have only ?success if possible ? Probably by treating it as a boolean
Contributor
|
I prefer option A as users are often "blind" to banners and flash messages. If you could just address my 2 comments i'll merge this 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Following your feedback, I investigated the Turbo console error instead of just disabling Turbo.
The Problem:
When the bulk upload form is submitted successfully, the
submit_bulkview directly returns arender()(HTTP 200 OK). Hotwire Turbo strictly enforces the Post/Redirect/Get (PRG) pattern and throws theForm responses must redirect to another locationerror if a POST request doesn't return a redirect.The Implemented Solution (Current PR):
I modified the
view.pyto respect the PRG pattern.HttpResponseRedirectto the same URL, appending a?success=1parameter.document_bulk.htmlsuccess page.Result: The console is perfectly clean, and Turbo handles the navigation smoothly.
Alternative Idea for the Future (Option B)
While this PR fixes the bug using the current UI, having a dedicated success page (
document_bulk.html) and?success=1in the URL might feel a bit heavy.As an alternative, we could completely remove this success page and use Django Flash Messages instead:
Let me know if you prefer to merge this PR as a quick fix, or if you'd like me to implement this "Flash Message" alternative instead!
Manual Testing:
Fixes #369