Opened 5 months ago
Closed 4 months ago
#36381 closed Cleanup/optimization (wontfix)
Improve tutorial's voting template to show a message when no choices are available
Reported by: | Birendra Kumar Sharma | Owned by: | Birendra Kumar Sharma |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | tutorial, documentation, template, |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
In the polls tutorial (polls/detail.html), the template currently loops over choices without showing anything if none exist.
This change adds a condition to display a user-friendly message ("No choices available for this question.") when no choices are present.
This improves clarity for beginners and makes the template more informative without altering existing functionality.
Change History (3)
comment:1 by , 4 months ago
Patch needs improvement: | set |
---|---|
Summary: | Improve tutorial template to show a message when no choices are available → Improve tutorial's voting template to show a message when no choices are available |
comment:2 by , 4 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 4 months ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
I agree with Tim here
I don't see a strong reason why adding more logic makes this clearer. I feel the tutorial should keep logic simple and focus on the concepts it's trying to introduce.
A question is not really "valid" without choices. The detail view also doesn't have an if/else condition. The user of the tutorial can make their own extensions adding logic to handle this
If you disagree, you can bring this up on the forum and add more reasoning: https://forum.djangoproject.com/c/internals/5
I'm not in love with the suggestion, but I'll leave the ticgket open for a second opinion. Tutorial 2 already shows how to add choices to a question, so that proposed section redundant. Tutorial 3 already shows how to use
{% if %}
/{% else %}
to show a "No items available" message. Finally, the patch contains some unneeded indentation changes.