2011-11-22 103 views

回答

4

您可以添加功能,以您的TabularInline,然後告訴他們作爲字段:

class MyTabularInline(admin.TabularInline): 
    model = MyModel 
    readonly_fields = ['decrypt_first_field', 'decrypt_second_field'] 

    def decrypt_first_field(self, obj): 
     if obj.first_field: 
      return decrypt(obj.first_field) 
     else: 
      return 'Nothing here ...' 

    def decrypt_first_field(self, obj): 
     ...