Readonly fields in the django admin/inline

后端 未结 3 948
逝去的感伤
逝去的感伤 2021-02-08 09:24

I use this snippet to show several fields in my admin backend as readonly, but as noticed in the comments, it does not work on stackedinline/tabularinline. Is there any other wa

3条回答
  •  無奈伤痛
    2021-02-08 10:22

    If you are running Django 1.3 or later; there's an attribute named ModelAdmin.readonly_fields which you could use.

    InlineModelAdmin inherits from ModelAdmin, so you should be able to use it from your inline subclass.

提交回复
热议问题