22import logging
33
44from django .contrib import admin
5+ from django .utils import timezone
56from django .utils .html import format_html
67
78from django_db_logger .config import DJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGE
1011
1112class StatusLogAdmin (admin .ModelAdmin ):
1213 list_display = ('colored_msg' , 'traceback' , 'create_datetime_format' )
13- list_display_links = ('colored_msg' , )
14- list_filter = ('level' , )
14+ list_display_links = ('colored_msg' ,)
15+ list_filter = ('level' ,)
1516 list_per_page = DJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGE
1617
1718 def colored_msg (self , instance ):
@@ -22,14 +23,16 @@ def colored_msg(self, instance):
2223 else :
2324 color = 'red'
2425 return format_html ('<span style="color: {color};">{msg}</span>' , color = color , msg = instance .msg )
26+
2527 colored_msg .short_description = 'Message'
2628
2729 def traceback (self , instance ):
2830 return format_html ('<pre><code>{content}</code></pre>' , content = instance .trace if instance .trace else '' )
2931
3032 def create_datetime_format (self , instance ):
31- return instance .create_datetime .strftime ('%Y-%m-%d %X' )
33+ return timezone .localtime (instance .create_datetime ).strftime ('%Y-%m-%d %X' )
34+
3235 create_datetime_format .short_description = 'Created at'
3336
3437
35- admin .site .register (StatusLog , StatusLogAdmin )
38+ admin .site .register (StatusLog , StatusLogAdmin )
0 commit comments