Opened 3 months ago
Closed 3 months ago
#35748 closed Cleanup/optimization (fixed)
Document that Field.formfield() may return None
Reported by: | Adam Johnson | Owned by: | Clifford Gama |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The current documentation only states that a form field should be returned. None
is also an allowed return value, as used by AutoFieldMixin, used to ignore the field when constructing the model form.
(Updating django-stubs types in this PR.)
Change History (7)
comment:1 by , 3 months ago
Description: | modified (diff) |
---|
comment:2 by , 3 months ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 3 months ago
Yes, let’s update both the reference doc section and add an example under “Specifying the form field for a model field”.
comment:4 by , 3 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:6 by , 3 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Be good to say somewhere that overwriting this to return None will make it an ignored form field
Might belong here: https://docs.djangoproject.com/en/dev/howto/custom-model-fields/#specifying-form-field-for-model-field