Ticket #15221: 15221_m2m_filterspec_title.diff

File 15221_m2m_filterspec_title.diff, 1.1 KB (added by Julien Phalip, 14 years ago)
  • django/contrib/admin/filterspecs.py

    diff --git a/django/contrib/admin/filterspecs.py b/django/contrib/admin/filterspecs.py
    index eab5407..c2da791 100644
    a b class RelatedFilterSpec(FilterSpec):  
    6868            f, request, params, model, model_admin, field_path=field_path)
    6969
    7070        other_model = get_model_from_relation(f)
    71         if isinstance(f, (models.ManyToManyField,
    72                           models.related.RelatedObject)):
    73             # no direct field on this model, get name from other model
    74             self.lookup_title = other_model._meta.verbose_name
     71        if hasattr(f, 'verbose_name') and f.verbose_name != u'':
     72            self.lookup_title = f.verbose_name
    7573        else:
    76             self.lookup_title = f.verbose_name # use field name
     74            self.lookup_title = other_model._meta.verbose_name
    7775        rel_name = other_model._meta.pk.name
    7876        self.lookup_kwarg = '%s__%s__exact' % (self.field_path, rel_name)
    7977        self.lookup_val = request.GET.get(self.lookup_kwarg, None)
Back to Top