#13883: SelectBox.js with grouping (optgroup elements)
-------------------------------------------+--------------------------------
Reporter: SardarNL | Owner: nobody
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: 1.2
Resolution: | Keywords: admin, SelectBox,
optgroup, sprintdec2010
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by julien):
* keywords: admin, SelectBox, optgroup => admin, SelectBox, optgroup,
sprintdec2010
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
It looks good and it mostly works, except that the add popup (which
appears after clicking the green cross icon) does not work properly. Could
you revisit your patch to fix this?
By the way, in the future it would make it a lot easier for anyone to
review your patch if you:
* sent a diff instead of a whole file.
* provided a simple test case so that it's easier for people to reproduce
the problem you're trying to solve.
I'm uploading a diff now. I've also produced the following test case:
Models:
{{{
#!python
from django.db import models
class Sport(models.Model):
name = models.CharField(max_length=100)
is_team_sport = models.BooleanField(default=False)
def __unicode__(self):
return self.name
class Profile(models.Model):
sports = models.ManyToManyField(Sport)
}}}
Admin:
{{{
#!python
from django.contrib import admin
from django.forms import ModelForm
from .models import Sport, Profile
class ProfileForm(ModelForm):
def __init__(self, *args, **kwargs):
super(ProfileForm, self).__init__(*args, **kwargs)
team_sports = []
single_sports = []
for sport in Sport.objects.all():
if sport.is_team_sport:
team_sports.append((sport.name, sport.name))
else:
single_sports.append((sport.name, sport.name))
self.fields['sports'].choices = [['Team Sports', team_sports],
['Single Sports', single_sports]]
class ProfileAdmin(admin.ModelAdmin):
form = ProfileForm
filter_horizontal = ('sports',)
admin.site.register(Profile, ProfileAdmin)
admin.site.register(Sport)
}}}
This can be considered as a usability bug so keeping in the 1.3 milestone.
--
Ticket URL: <http://code.djangoproject.com/ticket/13883#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.