#37186: Document form Field's template_name argument
-------------------------------------+-------------------------------------
Reporter: Tim Schilling | Type:
| Cleanup/optimization
Status: new | Component:
| Documentation
Version: dev | Severity: Normal
Keywords: form rendering | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
The change to support form field rendering in Ticket #34077 stopped short
of documenting that a field can have a customized template specified on
the field itself. This template would be passed to the
[
https://docs.djangoproject.com/en/6.0/ref/forms/api/#django.forms.BoundField.template_name
BoundField which we have public documentation] for.
This change would mean documenting `template_name` in the
[
https://github.com/django/django/blob/a6cfda9afaf924c2793df757c85eba5a3b5b2f13/django/forms/fields.py#L137
Field.__init__ method here].
I suppose one reason to not do this is if this particular API isn't
something we want to commit to. I think since it hasn't changed in a few
years, it appears stable.
The usage we'd want to make developers aware of is that they can do today:
{{{
class ProfileForm(forms.Form):
image = forms.ImageField(
template_name="my_forms/fields/image_with_preview.html"
)
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/37186>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.