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

前端 未结 3 2061
鱼传尺愫
鱼传尺愫 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 22:53

    Your read-only fields must be in fields also:

    fields = ['title', 'author', 'content', 'published_date', 'updated_date', 'created_date']
    readonly_fields = ('published_date', 'updated_date', 'created_date')
    

提交回复
热议问题