diff -r 96debd1bb75f django/contrib/admin/widgets.py
a
|
b
|
|
167 | 167 | super(ManyToManyRawIdWidget, self).__init__(rel, attrs, using=None) |
168 | 168 | |
169 | 169 | def render(self, name, value, attrs=None): |
| 170 | if attrs is None: |
| 171 | attrs = {} |
170 | 172 | attrs['class'] = 'vManyToManyRawIdAdminField' |
171 | 173 | if value: |
172 | 174 | value = ','.join([str(v) for v in value]) |
diff -r 96debd1bb75f tests/regressiontests/admin_widgets/models.py
a
|
b
|
|
36 | 36 | return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False) |
37 | 37 | |
38 | 38 | class Inventory(models.Model): |
39 | | barcode = models.PositiveIntegerField(unique=True) |
40 | | parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True) |
41 | | name = models.CharField(blank=False, max_length=20) |
42 | | hidden = models.BooleanField(default=False) |
| 39 | barcode = models.PositiveIntegerField(unique=True) |
| 40 | parent = models.ForeignKey('self', to_field='barcode', blank=True, null=True) |
| 41 | name = models.CharField(blank=False, max_length=20) |
| 42 | hidden = models.BooleanField(default=False) |
43 | 43 | |
44 | | # see #9258 |
45 | | default_manager = models.Manager() |
46 | | objects = HiddenInventoryManager() |
| 44 | # see #9258 |
| 45 | default_manager = models.Manager() |
| 46 | objects = HiddenInventoryManager() |
47 | 47 | |
48 | | def __unicode__(self): |
49 | | return self.name |
| 48 | def __unicode__(self): |
| 49 | return self.name |
50 | 50 | |
51 | 51 | class Event(models.Model): |
52 | 52 | band = models.ForeignKey(Band, limit_choices_to=models.Q(pk__gt=0)) |
diff -r 96debd1bb75f tests/regressiontests/admin_widgets/tests.py
a
|
b
|
|
83 | 83 | def testRawIDManyTOMany(self): |
84 | 84 | self.assertFormfield(models.Band, 'members', widgets.ManyToManyRawIdWidget, |
85 | 85 | raw_id_fields=['members']) |
| 86 | rel = models.Band._meta.get_field('members').rel |
| 87 | w = widgets.ManyToManyRawIdWidget(rel) |
| 88 | w.render("foo","bar") |
| 89 | |
86 | 90 | |
87 | 91 | def testFilteredManyToMany(self): |
88 | 92 | self.assertFormfield(models.Band, 'members', widgets.FilteredSelectMultiple, |