Opened 10 days ago

Last modified 8 days ago

#35748 assigned Cleanup/optimization

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: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Adam Johnson)

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 (5)

comment:1 by Adam Johnson, 10 days ago

Description: modified (diff)

comment:2 by Sarah Boyce, 10 days ago

Triage Stage: UnreviewedAccepted

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

comment:3 by Adam Johnson, 10 days 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 Clifford Gama, 9 days ago

Owner: set to Clifford Gama
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top