2011-04-08 212 views

回答

0
class WhateverAdmin(django.contrib.admin.ModelAdmin): 

    def filtered_url_filed(self): 
     return '' if self.url_field == self.url_filed.default else self.url_field 

    list_display(... 
       'filtered_url_field', 
       ...) 
0

難道我理解正確的話,你想,沒有任何鏈接的顯示列表?如果是這樣,那麼你不能做一些骯髒的黑客攻擊。這裏是怎麼作弊Django管理爲例:

class CheatListDisplayLinks(list): 

    def __init__(self, *args): 
     self.extend(args) 

    def __contains__(self, item): 
     if item == 'cheat_field': 
      return True 
     return super(CheatListDisplayLinks, self).__contains__(item) 

class GalleryAdmin(admin.ModelAdmin): 
    list_display = CheatListDisplayLinks('name', 'last_updated') 
    list_display_links = ['cheat_field']