Django admin:如何在模型中显示标记为editable = False的字段?
问题描述:
即使一个字段在模型中被标记为'editable = False'
,我希望管理页面显示它。目前它完全隐藏了这个领域..如何实现?
Even though a field is marked as 'editable=False'
in the model, I would like the admin page to display it. Currently it hides the field altogether.. How can this be achieved ?
答
使用 Readonly Fields 。像这样(对于django> = 1.2):
Use Readonly Fields. Like so (for django >= 1.2):
class MyModelAdmin(admin.ModelAdmin):
readonly_fields=('first',)