Django admin: How to display a field that is marked as editable=False' in the model?

前端 未结 3 2075
鱼传尺愫
鱼传尺愫 2020-11-28 22:36

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 t

3条回答
  •  孤街浪徒
    2020-11-28 23:02

    Use Readonly Fields. Like so (for django >= 1.2):

    class MyModelAdmin(admin.ModelAdmin):
        readonly_fields=('first',)
    

提交回复
热议问题