<s> from datetime import datetime <EOL> from django . contrib import admin <EOL> from django . db . models import Count <EOL> from . models import Post <EOL> @ admin . register ( Post ) <EOL> class PostAdmin ( admin . ModelAdmin ) : <EOL> date_hierarchy = '<STR_LIT>' <EOL> list_display = ( <EOL> '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> search_fields = ( '<STR_LIT:title>' , '<STR_LIT:text>' ) <EOL> fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:text>' , <EOL> ) } ) , <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) } ) , <EOL> ) <EOL> filter_horizontal = ( '<STR_LIT>' , '<STR_LIT>' , ) <EOL> prepopulated_fields = { "<STR_LIT>" : ( "<STR_LIT:title>" , ) } <EOL> def get_queryset ( self , request ) : <EOL> queryset = super ( ) . get_queryset ( request ) <EOL> if not request . user . has_perms ( <EOL> '<STR_LIT>' ) : <EOL> queryset = queryset . filter ( <EOL> pub_date__lte = datetime . now ( ) ) <EOL> return queryset . annotate ( <EOL> tag_number = Count ( '<STR_LIT>' ) ) <EOL> def tag_count ( self , post ) : <EOL> return post . tag_number <EOL> tag_count . short_description = '<STR_LIT>' <EOL> tag_count . admin_order_field = '<STR_LIT>' </s>
