Opened 5 years ago
Closed 5 years ago
#32706 closed Cleanup/optimization (invalid)
Ambiguity around field choices in the Model Field section
| Reported by: | Logan Kilpatrick | Owned by: | nobody |
|---|---|---|---|
| Component: | Documentation | Version: | 3.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I am reading here: https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.Field.choices about field choices. The docs remark that:
"Generally, it’s best to define choices inside a model class, and to define a suitably-named constant for each value:"
Why is this? Looking at the code, it is not abundantly clear to me as a developer why this is the case. I think folks would benefit from a sentence or two of commentary as to why this approach is generally better.
Note:
See TracTickets
for help on using tickets.
This is briefly explained in the same paragraph, just below the example:
I think it's sufficient.