Fix sortable cols in admin

This commit is contained in:
Matthew Ryan Dillon 2016-01-29 11:53:33 -07:00
parent 53f28be5ec
commit c4b8911cc4
3 changed files with 63 additions and 8 deletions

View file

@ -27,7 +27,7 @@ class GrantAdmin(admin.ModelAdmin):
class GrantReportAdmin(admin.ModelAdmin):
list_display = ('grant', 'title', 'report_type', 'description', 'due_date',
list_display = ('grant_title', 'title', 'report_type', 'description', 'due_date',
'submitted_date', 'attachment', 'sort_order')
list_display_links = ('title',)
search_fields = ('grant__title', 'title', 'report_type', 'description', 'due_date',
@ -36,6 +36,11 @@ class GrantReportAdmin(admin.ModelAdmin):
fields = ('title', 'report_type', 'description', 'due_date',
'submitted_date', 'attachment', 'sort_order')
def grant_title(self, obj):
return obj.grant.title
grant_title.admin_order_field = 'grant__title'
grant_title.short_description = 'Grant'
admin.site.register(Project, ProjectAdmin)
admin.site.register(Grant, GrantAdmin)