[Django] #29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a Space

24 views
Skip to first unread message

Django

unread,
Jun 11, 2018, 7:55:07 PM6/11/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark | Owner: nobody
Phillips |
Type: Bug | Status: new
Component: | Version: 2.0
Uncategorized | Keywords:
Severity: Normal | FilteredSelectMultiple widget
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
If the label for the FilteredSelectMultiple has a space in it, the
controls for moving data between the boxes are not activated. The widget
still works if one double clicks on the elements in the left box, they
move to the right box. But the arrows don't work. Tested on Chrome
67.0.3396.62 (Official Build) (64-bit) and Firefox 60.0.1 (64-bit) using
runserver to run my django code.

Take a look at the attached image first.png. There are two
FilteredSelectMultiple widgets, one called Pets and one called Pet Names.
Note that in the widget Pet Names, the controls are not highlighted, but
the controls in the Pets widget are highlighted.

Take a look at the attached image second.png. The only change to the code
was to change the Pet Names label to Pet_Names (ie replaced the space
between Pet and Names with an underscore Pet Names -> Pet_Names). Now the
controls are working.

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

Django

unread,
Jun 11, 2018, 7:56:18 PM6/11/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Phillips):

* Attachment "first.png" added.

Screen shot showing a FilteredSelectMultiple widget with a space in the
label and the controls not working.

Django

unread,
Jun 11, 2018, 7:56:50 PM6/11/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: Uncategorized | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Phillips):

* Attachment "second.png" added.

Screen shot showing a FilteredSelectMultiple widget without a space in the
label and the controls are working.

Django

unread,
Jun 11, 2018, 8:01:50 PM6/11/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: Uncategorized | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Mark Phillips:

Old description:

> If the label for the FilteredSelectMultiple has a space in it, the
> controls for moving data between the boxes are not activated. The widget
> still works if one double clicks on the elements in the left box, they
> move to the right box. But the arrows don't work. Tested on Chrome
> 67.0.3396.62 (Official Build) (64-bit) and Firefox 60.0.1 (64-bit) using
> runserver to run my django code.
>
> Take a look at the attached image first.png. There are two
> FilteredSelectMultiple widgets, one called Pets and one called Pet Names.
> Note that in the widget Pet Names, the controls are not highlighted, but
> the controls in the Pets widget are highlighted.
>
> Take a look at the attached image second.png. The only change to the code
> was to change the Pet Names label to Pet_Names (ie replaced the space
> between Pet and Names with an underscore Pet Names -> Pet_Names). Now the
> controls are working.

New description:

If the label for the FilteredSelectMultiple has a space in it, the
controls for moving data between the boxes are not activated. The widget
still works if one double clicks on the elements in the left box, they
move to the right box. But the arrows don't work. Tested on Chrome
67.0.3396.62 (Official Build) (64-bit) and Firefox 60.0.1 (64-bit) using
runserver to run my django code.

Take a look at the attached image first.png. There are two
FilteredSelectMultiple widgets, one called Pets and one called Pet Names.
Note that in the widget Pet Names, the controls are not highlighted, but
the controls in the Pets widget are highlighted.

Take a look at the attached image second.png. The only change to the code
was to change the Pet Names label to Pet_Names (ie replaced the space
between Pet and Names with an underscore Pet Names -> Pet_Names). Now the
controls are working.

Mark

--

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

Django

unread,
Jun 12, 2018, 9:00:50 AM6/12/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.0

Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* component: Uncategorized => contrib.admin


Comment:

I'm not sure that a space in the label is the issue. For example, I
couldn't reproduce the problem with "Available user permissions" on the
change user page. Could you debug a bit further and confirm the source of
the problem?

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

Django

unread,
Jun 12, 2018, 1:16:18 PM6/12/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Phillips):

I am happy to help debug this issue. I am not sure where to start or how
to proceed. Any suggestions as to a plan of attack would be very helpful!

Replying to [comment:2 Tim Graham]:


> I'm not sure that a space in the label is the issue. For example, I
couldn't reproduce the problem with "Available user permissions" on the
change user page. Could you debug a bit further and confirm the source of
the problem?

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:3>

Django

unread,
Jun 12, 2018, 1:57:55 PM6/12/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

I would try some JavaScript debugging in
`django/contrib/admin/static/admin/js/SelectFilter2.js`.

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:4>

Django

unread,
Jun 13, 2018, 4:39:56 AM6/13/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* cc: Carlton Gibson (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:5>

Django

unread,
Jun 13, 2018, 8:19:05 PM6/13/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Phillips):

Tim,

I am not a Javascript guy, but I did manage to get this far - perhaps it
will help.

In SelectFilter2.js, I tracked what was going on to the line where it is
going to toggle the add link on (see picture A). When I step through the
code using the widget named Pets and selecting an element, I get to
picture B in the bowels of the jQuery code. You will note that "match = 3"
for this control. When I step through the same code, but select an element
in Pet Names, I get to the same place, but now match = null (picture C).
From here, the program goes in different directions, and not being a js
guy, I am a little lost.

I hope this helps!

Mark

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:6>

Django

unread,
Jun 13, 2018, 8:23:30 PM6/13/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Phillips):

Tim,

I can't upload the three images because the tracker thinks they are spam.

Mark

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:7>

Django

unread,
Jun 13, 2018, 9:53:47 PM6/13/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Phillips):

* Attachment "Javascrpt debugging A.png" added.

Javascript debugging A

Django

unread,
Jun 13, 2018, 9:54:36 PM6/13/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Phillips):

* Attachment "Javascript debugging B.png" added.

Javascript debugging B

Django

unread,
Jun 13, 2018, 9:54:52 PM6/13/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Phillips):

* Attachment "Javascript debugging C.png" added.

Javascript debugging C

Django

unread,
Jun 13, 2018, 9:55:29 PM6/13/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Phillips):

Finally found a file name that was not considered spam.....

Mark

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:8>

Django

unread,
Jun 15, 2018, 9:51:16 AM6/15/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Can you provide a sample project with the minimal code needed to reproduce
the issue?

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:9>

Django

unread,
Jun 15, 2018, 12:16:58 PM6/15/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Phillips):

Tim,

The project is rather large. I can try to trim it down, but I am in the
middle of fixing other bugs right now. In what form and how should I send
you the trimmed down project?

Mark

PS Sorry for my newbieness...;)

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:10>

Django

unread,
Jun 15, 2018, 12:42:33 PM6/15/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: closed

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
| worksforme

Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => worksforme


Comment:

You can attach a file on the ticket or put the minimal project on GitHub.
I tried this but could not reproduce the problem:
{{{
from django.db import models


class Pet(models.Model):
name = models.CharField(max_length=20)

def __str__(self):
return self.name

class PetName(models.Model):
name = models.CharField(max_length=20)

def __str__(self):
return self.name

class Whatever(models.Model):
pets = models.ManyToManyField(Pet)
pet_names = models.ManyToManyField(PetName)
}}}
{{{
from django.contrib import admin

from .models import Pet, PetName, Whatever

admin.site.register((Pet, PetName))
admin.site.register(Whatever, filter_horizontal=['pets', 'pet_names'])
}}}
The widget says, "Available pet names".

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:11>

Django

unread,
Jun 15, 2018, 6:09:17 PM6/15/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
| worksforme
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mark Phillips):

Tim,

After looking at your example, I see I did a bad job of explaining the
bug. In my program, I create the fields for the adminForm on the fly
because the fields are not defined until run time. I have these lines of
code:


{{{
class MetaDataNames(models.Model):
meta_name_id = models.AutoField(primary_key = True)
name = models.CharField(max_length=200, unique=True)

class MetaDataValues(models.Model):
meta_value_id = models.AutoField(primary_key = True)
meta_name_id = models.ForeignKey(MetaDataNames,
on_delete=models.CASCADE,)
value = models.CharField(max_length=200, unique=True)

class Document(models.Model):
test_id = models.AutoField(primary_key = True)
doc_name = models.CharField(max_length=200, unique=True)
metadata = jsonfield.JSONField(blank=True)

This lines of code in the DocumentAdminForm(forms.ModelForm) contains :

def __init__(self, *args, **kwargs):
metadata_names = MetaDataNames.objects.all()
# create the fields
for metadata in metadata_names:
self.fields[metadata.name] =
forms.ModelMultipleChoiceField(widget=FilteredSelectMultiple(metadata.name,
is_stacked=False), required=False,
queryset=MetaDataValues.objects.filter(meta_name_id=metadata.meta_name_id).order_by('value'),)
.....
}}}

The issue with the FilteredSelectMultiple widget is that when the field
name has a space, the controls don't work. In the code above, where it
says self.fields[metadata.name], the metadata.name part is the string 'Pet
Names', with a space. If I use 'Pet_Names', then the controls in the
widget work.

I may be offending the Django Gods by having a field name with a space in
it. One cannot do that in a model, as far as I can figure out. However, it
is an interesting edge case for the widget, since it is perfectly
reasonable for one to create fields as I am doing.

I can continue to create the test case based on the above code if you
want. However, if the answer is that I cannot have a field name with a
space, then I won't bother.

Please let me know if I should continue with a full test case, or that
nothing will be done because I have a field name with a space in it.

Thanks,

Mark

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:12>

Django

unread,
Jun 15, 2018, 7:21:21 PM6/15/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Phillips):

* status: closed => new
* resolution: worksforme =>


Comment:

I have attached a test django application (testFSM) that shows the
behavior I am seeing. It was tested using Django 2.0.5 and Python 3.4.3 in
a virtualenv on Ubuntu 14.04.

To recap:

If a field has a space in the field name for a ModelMultipleChoiceField
(ie fields are generated in the __init__ function of a ModelForm), then
the controls for the associated FilteredSelectMultiple widget are not
enabled. One can still double click on an element in the widget, but the
controls don't work. Also, one cannot clear the selected items or deselect
the items in the list.

Please see the README in the attached django project.

Mark

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:13>

Django

unread,
Jun 15, 2018, 7:22:37 PM6/15/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mark Phillips):

* Attachment "testFSM.zip" added.

Django project that illustrates the bug in a FilteredSelectMultiple widget
with a space in the field name

Django

unread,
Jun 15, 2018, 7:45:05 PM6/15/18
to django-...@googlegroups.com
#29488: FilteredSelectMultiple Controls Don't Work if The Name of the Widget Has a
Space
-------------------------------------+-------------------------------------
Reporter: Mark Phillips | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
FilteredSelectMultiple widget | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed

* resolution: => wontfix


Comment:

Thanks for the clarification. #29011 also raised an issue with spaces in
field names. I'll reiterate my position there and say that I don't see
much value in trying to fix issues such as spaces in field names that
can't occur with normal declarative forms.

--
Ticket URL: <https://code.djangoproject.com/ticket/29488#comment:14>

Reply all
Reply to author
Forward
0 new messages