[Django] #29011: forms.Field with space in dynamically generated forms.Form leads to wrong assigned id in generated HTML form

1 view
Skip to first unread message

Django

unread,
Jan 11, 2018, 8:31:26 AM1/11/18
to django-...@googlegroups.com
#29011: forms.Field with space in dynamically generated forms.Form leads to wrong
assigned id in generated HTML form
-----------------------------------------+------------------------
Reporter: pdehaye | Owner: nobody
Type: Uncategorized | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
If you do:

{{{
import django
from django.forms import Form
from django.forms import CharField
PersonForm = type('Person', (Form,), {"work
address":CharField(max_length=128)})
person = PersonForm()
person.as_ul()
}}}

You get
{{{
'<li><label for="id_work address">Work address:</label> <input type="text"
name="work address" maxlength="128" required id="id_work address" /></li>'
}}}

I think the `id="id_work address" ` is suboptimal here. At least the doc,
which references `id_<field-name>`, should be improved (also present in
2.0 doc)

--
Ticket URL: <https://code.djangoproject.com/ticket/29011>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 11, 2018, 8:32:04 AM1/11/18
to django-...@googlegroups.com
#29011: forms.Field with space in dynamically generated forms.Form leads to wrong
assigned id in generated HTML form
-------------------------------+--------------------------------------

Reporter: pdehaye | Owner: nobody
Type: Uncategorized | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by pdehaye:

Old description:

> If you do:
>
> {{{
> import django
> from django.forms import Form
> from django.forms import CharField
> PersonForm = type('Person', (Form,), {"work
> address":CharField(max_length=128)})
> person = PersonForm()
> person.as_ul()
> }}}
>
> You get
> {{{
> '<li><label for="id_work address">Work address:</label> <input
> type="text" name="work address" maxlength="128" required id="id_work
> address" /></li>'
> }}}
>
> I think the `id="id_work address" ` is suboptimal here. At least the doc,
> which references `id_<field-name>`, should be improved (also present in
> 2.0 doc)

New description:

If you do:

{{{
import django
from django.forms import Form
from django.forms import CharField
PersonForm = type('Person', (Form,), {"work
address":CharField(max_length=128)})
person = PersonForm()
person.as_ul()
}}}

You get
{{{
'<li><label for="id_work address">Work address:</label> <input type="text"
name="work address" maxlength="128" required id="id_work address" /></li>'
}}}

I think the `id="id_work address" ` is suboptimal here. Maybe everything
should be underscored? At least the doc, which references `id_<field-


name>`, should be improved (also present in 2.0 doc)

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29011#comment:1>

Django

unread,
Jan 11, 2018, 9:04:24 AM1/11/18
to django-...@googlegroups.com
#29011: forms.Field with space in dynamically generated forms.Form leads to wrong
assigned id in generated HTML form
-------------------------------------+-------------------------------------
Reporter: pdehaye | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Forms | Version: 1.11
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* type: Uncategorized => Cleanup/optimization
* resolution: => wontfix


Comment:

I don't see a strong argument for making a change here. If you're
generating field names that aren't valid when using a normal declarative
form, you're on your own. I don't think this is a normal use case that
needs documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/29011#comment:2>

Reply all
Reply to author
Forward
0 new messages