(self, instance)
return '<div class="dropdown related_menu pull-right"><a title="%s" class="relate_menu dropdown-toggle" data-toggle="dropdown"><i class="icon fa fa-list"></i></a>%s</div>' % (_('Related Objects'), ul_html)
外键关联菜单列
外键关联菜单列
外键关联菜单列
def related_link(self, instance):
        '''
        外键关联菜单列
        '''
        links = []
        for r, view_perm, add_perm in self.get_related_list():
            info = RelateMenuPlugin.get_r_model_info(r)
            label = info['label']
            model_name = info['model_name']
            lookup_name = info['lookup_name']
            verbose_name = info['verbose_name']

            _tojoin = [ '<li class="with_menu_btn">' ]

            if view_perm:
                list_url = reverse('%s:%s_%s_changelist' % (self.admin_site.app_name, label, model_name) )
                str1 = '<a href="%s?%s=%s" title="查看%s"><i class="icon fa fa-th-list"></i> %s</a>' %(
                                                                                                  list_url,
                                                                                                  RELATE_PREFIX + lookup_name, str(instance.pk),
                                                                                                  verbose_name,
                                                                                                  verbose_name
                                                                                                  )
            else:
                str1 = '<a><span class="text-muted"><i class="icon fa fa-blank"></i> %s</span></a>' % verbose_name
            _tojoin.append(str1)

            if add_perm:
                add_url = reverse('%s:%s_%s_add' % (self.admin_site.app_name, label, model_name) )
                str2 = '<a class="add_link dropdown-menu-btn" href="%s?%s=%s" title="添加%s"><i class="icon fa fa-plus pull-right"></i></a>' %(
                                                                                                  add_url,
                                                                                                  RELATE_PREFIX + lookup_name,
                                                                                                  str(instance.pk),
                                                                                                  verbose_name
                                                                                                  )
            else:
                str2 = ''
            _tojoin.append(str2)

            link = ''.join(_tojoin)
            links.append(link)
        ul_html = '<ul class="dropdown-menu" role="menu">%s</ul>' % ''.join(links)
        return '<div class="dropdown related_menu pull-right"><a title="%s" class="relate_menu dropdown-toggle" data-toggle="dropdown"><i class="icon fa fa-list"></i></a>%s</div>' % (_('Related Objects'), ul_html)
def related_link ( self , instance ) : links = [ ] for r , view_perm , add_perm in self . get_related_list ( ) : info = RelateMenuPlugin . get_r_model_info ( r ) label = info [ 'label' ] model_name = info [ 'model_name' ] lookup_name = info [ 'lookup_name' ] verbose_name = info [ 'verbose_name' ] _tojoin = [ '<li class="with_menu_btn">' ] if view_perm : list_url = reverse ( '%s:%s_%s_changelist' % ( self . admin_site . app_name , label , model_name ) ) str1 = '<a href="%s?%s=%s" title="查看%s"><i class="icon fa fa-th-list"></i> %s</a>' %( list_url , RELATE_PREFIX + lookup_name , str ( instance . pk ) , verbose_name , verbose_name ) else : str1 = '<a><span class="text-muted"><i class="icon fa fa-blank"></i> %s</span></a>' % verbose_name _tojoin . append ( str1 ) if add_perm : add_url = reverse ( '%s:%s_%s_add' % ( self . admin_site . app_name , label , model_name ) ) str2 = '<a class="add_link dropdown-menu-btn" href="%s?%s=%s" title="添加%s"><i class="icon fa fa-plus pull-right"></i></a>' %( add_url , RELATE_PREFIX + lookup_name , str ( instance . pk ) , verbose_name ) else : str2 = '' _tojoin . append ( str2 ) link = '' . join ( _tojoin ) links . append ( link ) ul_html = '<ul class="dropdown-menu" role="menu">%s</ul>' % '' . join ( links ) return '<div class="dropdown related_menu pull-right"><a title="%s" class="relate_menu dropdown-toggle" data-toggle="dropdown"><i class="icon fa fa-list"></i></a>%s</div>' % ( _ ( 'Related Objects' ) , ul_html )