Opened 6 years ago
Closed 6 years ago
#31189 closed Cleanup/optimization (wontfix)
Password field help texts generates invalid html when using as_p() and as_table() helpers.
| Reported by: | Marc Nieper-Wißkirchen | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.auth | Version: | 3.0 |
| 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 (last modified by )
The help text for the password field of, say, the UserCreationForm, is generated here: https://github.com/django/django/blob/master/django/contrib/auth/password_validation.py#L78 and is an html list. The form methods, as_table' and as_p', however, wrap the help text into a span tag. In the resulting rendered HTML, there will thus be a ul tag inside a span tag, which is invalid html.
To solve this problem, the span tag needs at least to be a div. But then there is the problem that `as_p' renders everything inside a paragraph, which also cannot take an html list, only phrasing content.
Change History (2)
comment:1 by , 6 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 6 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Summary: | django.contrib.auth: Password field help text generates invalid html → Password field help texts generates invalid html when using as_p() and as_table() helpers. |
| Type: | Bug → Cleanup/optimization |
It was fixed in admins' templates in 2d26b4637f0318736955b54b34f270fe9500f795, see #27207.
Forms in
django.contrib.auth.formsare designed to render properly in Django admin and I don't think that we should override helpers in admin forms to generate valid HTML in all helpersas_ul(),as_p(), andas_table(), moreover even overridinghelp_text_htmlwon't help inas_p(). There's no feasible solution. You can re-use templates fromadmin/templates/admin, e.g.admin/templates/admin/includes/fieldset.htmlif you don't want to write you're own custom templates.