Opened 14 years ago
Closed 4 years ago
#14660 closed Bug (fixed)
Using a CheckboxSelectMultiple widget on a M to M field in Admin causes 'SelectBox is not defined' JS error in RelatedObjectLookups.js
Reported by: | sloggz | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
(Using Django 1.2.1)
Form and Model given like so:
forms.py:
class PictureGalleryForm(ModelForm): class Meta: model=PictureGallery widgets = { 'pictures' : CheckboxSelectMultiple, }
models.py:
class GalleryCommon(models.Model): date_created = models.DateTimeField(auto_now_add=True) date_updated = models.DateTimeField(auto_now=True) title = models.CharField(max_length=256) class Meta: abstract = True class PictureGallery(GalleryCommon): pictures = models.ManyToManyField(Picture, related_name="pic_gallery", help_text="Select Gallery Images.") def __unicode__(self): return (self.title)
To encounter the error, register PictureGallery with admin using the PictureGalleryForm and click the green plus arrow to add a picture.
On clicking the save button in the popup admin window, the picture will save, but the popup will hang at line 92 of RelatedObjectLookup.js .
The error is 'SelectBox is not defined.'
Assume this occurs because somehow the 'if' statement at line 76 goes wrong.
As best I can tell this is similar to tickets #7133, #5731, and #10191 but not the same.
Attachments (1)
Change History (11)
comment:1 by , 14 years ago
Component: | Uncategorized → django.contrib.admin |
---|
comment:2 by , 14 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
Attachment: | 14660_CheckboxSelectMultiple_js_support.diff added |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:5 by , 13 years ago
UI/UX: | set |
---|
comment:9 by , 12 years ago
If there was no choices (no checkboxes available in the page) the add another doesn't work. since the JS assumes that at least there is one choice present to append the new entry after it..
comment:10 by , 4 years ago
Has patch: | unset |
---|---|
Patch needs improvement: | unset |
Resolution: | → fixed |
Status: | new → closed |
UI/UX: | unset |
I could not reproduce this issue in Django 1.8+, I haven't checked with older versions.
Currently Django's Javascript doesn't seem to support the use of CheckboxSelectMultiple. Accepting this ticket on the principle that it's a shame and that it should. Attaching a patch that provides the wanted functionality, though it could probably be improved a little bit.