Ticket #14363: fix-None-attrs-with-tests.diff

File fix-None-attrs-with-tests.diff, 2.4 KB (added by David Novakovic, 14 years ago)
  • django/contrib/admin/widgets.py

    diff -r 96debd1bb75f django/contrib/admin/widgets.py
    a b  
    167167        super(ManyToManyRawIdWidget, self).__init__(rel, attrs, using=None)
    168168
    169169    def render(self, name, value, attrs=None):
     170        if attrs is None:
     171            attrs = {}
    170172        attrs['class'] = 'vManyToManyRawIdAdminField'
    171173        if value:
    172174            value = ','.join([str(v) for v in value])
  • tests/regressiontests/admin_widgets/models.py

    diff -r 96debd1bb75f tests/regressiontests/admin_widgets/models.py
    a b  
    3636        return super(HiddenInventoryManager, self).get_query_set().filter(hidden=False)
    3737
    3838class 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)
    4343
    44    # see #9258
    45    default_manager = models.Manager()
    46    objects = HiddenInventoryManager()
     44    # see #9258
     45    default_manager = models.Manager()
     46    objects = HiddenInventoryManager()
    4747
    48    def __unicode__(self):
    49       return self.name
     48    def __unicode__(self):
     49        return self.name
    5050
    5151class Event(models.Model):
    5252    band = models.ForeignKey(Band, limit_choices_to=models.Q(pk__gt=0))
  • tests/regressiontests/admin_widgets/tests.py

    diff -r 96debd1bb75f tests/regressiontests/admin_widgets/tests.py
    a b  
    8383    def testRawIDManyTOMany(self):
    8484        self.assertFormfield(models.Band, 'members', widgets.ManyToManyRawIdWidget,
    8585                             raw_id_fields=['members'])
     86        rel = models.Band._meta.get_field('members').rel
     87        w = widgets.ManyToManyRawIdWidget(rel)
     88        w.render("foo","bar")
     89       
    8690
    8791    def testFilteredManyToMany(self):
    8892        self.assertFormfield(models.Band, 'members', widgets.FilteredSelectMultiple,
Back to Top