#35748: Document that Field.formfield() may return None
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Adam Johnson:
Old description:
> The
> [https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.formfield
> current documentation] only states that a form field should be returned.
> `None` is also an allowed return value,
> [https://github.com/django/django/blob/cdbd31960e0cf41063b3efac97292ee0ccc262bb/django/db/models/fields/__init__.py#L2828-L2829
> as used by AutoFieldMixin], used to
> [https://github.com/django/django/blob/cdbd31960e0cf41063b3efac97292ee0ccc262bb/django/forms/models.py#L236-L248
> ignore the field] when constructing the model form.
New description:
The
[https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.formfield
current documentation] only states that a form field should be returned.
`None` is also an allowed return value,
[https://github.com/django/django/blob/cdbd31960e0cf41063b3efac97292ee0ccc262bb/django/db/models/fields/__init__.py#L2828-L2829
as used by AutoFieldMixin], used to
[https://github.com/django/django/blob/cdbd31960e0cf41063b3efac97292ee0ccc262bb/django/forms/models.py#L236-L248
ignore the field] when constructing the model form.
(Updating django-stubs types [https://github.com/typeddjango/django-
stubs/pull/2363 in this PR].)
--
--
Ticket URL: <https://code.djangoproject.com/ticket/35748#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070191d70e5337-479ebaa0-17b1-40be-a120-294c6bed9ca2-000000%40eu-central-1.amazonses.com.