Ticket #11357: admindocs-m2m-both-ways.diff

File admindocs-m2m-both-ways.diff, 1.4 KB (added by James Bennett, 15 years ago)

New patch; respects both sides of the m2m

  • django/contrib/admindocs/views.py

     
    214214            'help_text': field.help_text,
    215215        })
    216216
     217    # Gather many-to-many fields.
     218    for field in opts.many_to_many:
     219        data_type = related_object_name = field.rel.to.__name__
     220        app_label = field.rel.to._meta.app_label
     221        verbose = utils.parse_rst((_("all related `%(app_label)s.%(data_type)s` objects")  % {'app_label': app_label, 'data_type': data_type}), 'model', _('model:') + data_type)
     222        fields.append({
     223            'name': "%s.all" % field.name,
     224            "data_type": data_type,
     225            "verbose": verbose,
     226            "help_text": "",
     227        })
     228
    217229    # Gather model methods.
    218230    for func_name, func in model.__dict__.items():
    219231        if (inspect.isfunction(func) and len(inspect.getargspec(func)[0]) == 1):
     
    233245            })
    234246
    235247    # Gather related objects
    236     for rel in opts.get_all_related_objects():
     248    for rel in opts.get_all_related_objects() + opts.get_all_related_many_to_many_objects():
    237249        verbose = _("related `%(app_label)s.%(object_name)s` objects") % {'app_label': rel.opts.app_label, 'object_name': rel.opts.object_name}
    238250        accessor = rel.get_accessor_name()
    239251        fields.append({
Back to Top