Ticket #1253: doc.py.diff

File doc.py.diff, 2.0 KB (added by the.twentysixth@…, 19 years ago)
  • doc.py

     
    137137    if not utils.docutils_is_available:
    138138        return missing_docutils_page(request)
    139139
    140     models = []
     140    m = []
    141141    for app in models.get_installed_model_modules():
    142142        for model in app._MODELS:
    143143            opts = model._meta
    144             models.append({
    145                 'name': '%s.%s' % (opts.app_label, opts.module_name),
     144            m.append({
     145                'name': '%s.%s' % (model.__module__, model.__name__),
    146146                'module': opts.app_label,
    147147                'class': opts.module_name,
    148148            })
    149     return render_to_response('admin_doc/model_index', {'models': models}, context_instance=RequestContext(request))
     149    return render_to_response('admin_doc/model_index', {'models': m}, context_instance=RequestContext(request))
    150150model_index = staff_member_required(model_index)
    151151
    152152def model_detail(request, model):
     
    154154        return missing_docutils_page(request)
    155155
    156156    try:
    157         model = models.get_app(model)
     157        comp = model.split('.')
     158        modulename = '.'.join(comp[:-1])
     159        modelname = comp[-1]
     160        mod = __import__(modulename, '', '', [''])
     161        model = getattr(mod, modelname)
    158162    except ImportError:
    159163        raise Http404
    160     opts = model.Klass._meta
     164    opts = model._meta
    161165
    162166    # Gather fields/field descriptions
    163167    fields = []
     
    168172            'verbose': field.verbose_name,
    169173            'help': field.help_text,
    170174        })
    171     for func_name, func in model.Klass.__dict__.items():
    172         if callable(func) and len(inspect.getargspec(func)[0]) == 0:
     175    for func_name, func in model.__dict__.items():
     176        if (inspect.isfunction(func) or inspect.ismethod(func)) and len(inspect.getargspec(func)[0]) == 0:
    173177            try:
    174178                for exclude in MODEL_METHODS_EXCLUDE:
    175179                    if func_name.startswith(exclude):
Back to Top