2010-02-10 73 views

回答

7

你就不能:

from django.contrib.admin.models import LogEntry 
admin.site.register(LogEntry) 

在你admin.py文件中的一个?我只是测试它,它是准系统,但它的工作原理。

您可能希望更具体一些,并为LogEntry创建一个ModelAdmin类,以提供更好的列表视图以及可能的一些过滤功能。但是,这应该工作。

7

这是我的版本。 Reference for fields available.

class LogAdmin(admin.ModelAdmin): 
    """Create an admin view of the history/log table""" 
    list_display = ('action_time','user','content_type','change_message','is_addition','is_change','is_deletion') 
    list_filter = ['action_time','user','content_type'] 
    ordering = ('-action_time',) 
    #We don't want people changing this historical record: 
    def has_add_permission(self, request): 
     return False 
    def has_change_permission(self, request, obj=None): 
     #returning false causes table to not show up in admin page :-(
     #I guess we have to allow changing for now 
     return True 
    def has_delete_permission(self, request, obj=None): 
     return False 
+0

可以使字段只读:'readonly_fields = [ '用户', 'CONTENT_TYPE', 'OBJECT_ID', 'object_repr', 'action_flag', 'change_message的']' - 你仍然是能够点击保存,但不作任何更改。 – EvdB 2011-07-21 14:20:56

相关问题