我有下面的代码,我已将描述更改为html safe。问题是订单不再有效,我无法将订单更改为'safe_description'。
class QuestionAdmin(admin.ModelAdmin):
list_display = ('safe_description',)
search_fields = ('description',)
ordering = ('description',)
def safe_description(self, obj):
return mark_safe(obj.description)
safe_description.short_description = 'Description'
答案 0 :(得分:2)
Django并不神奇地知道safe_description
已映射到您的description
列。
使用admin_order_field
属性
safe_description.admin_order_field = 'description'