Ticket #9994: to_field.diff

File to_field.diff, 1.5 KB (added by graveyboat, 3 years ago)

patch for Django 1.3.1

  • django/contrib/admin/filterspecs.py

    diff -rupN django/contrib/admin/filterspecs.py /usr/lib/python2.7/site-packages/django/contrib/admin/filterspecs.py
    old new class RelatedFilterSpec(FilterSpec): 
    7474            self.lookup_title = other_model._meta.verbose_name
    7575        else:
    7676            self.lookup_title = f.verbose_name # use field name
    77         rel_name = other_model._meta.pk.name
     77        rel_name = f.rel.get_related_field().name
    7878        self.lookup_kwarg = '%s__%s__exact' % (self.field_path, rel_name)
    7979        self.lookup_kwarg_isnull = '%s__isnull' % (self.field_path)
    8080        self.lookup_val = request.GET.get(self.lookup_kwarg, None)
  • django/contrib/admin/options.py

    diff -rupN django/contrib/admin/options.py /usr/lib/python2.7/site-packages/django/contrib/admin/options.py
    old new class BaseModelAdmin(object): 
    229229        for part in parts[:-1]:
    230230            field, _, _, _ = model._meta.get_field_by_name(part)
    231231            if hasattr(field, 'rel'):
    232                 model = field.rel.to
    233                 pk_attr_name = model._meta.pk.name
     232                pk_attr_name = field.rel.get_related_field().name
    234233            elif isinstance(field, RelatedObject):
    235234                model = field.model
    236235                pk_attr_name = model._meta.pk.name
Back to Top