Django admin - make all fields readonly

后端 未结 9 1207
春和景丽
春和景丽 2020-12-05 17:56

I\'m trying to make all fields readonly without listing them explicitly.

Something like:

class CustomAdmin(admin.ModelAdmin):
    def get_readonly_fi         


        
9条回答
  •  感动是毒
    2020-12-05 18:23

    @admin.register(Hero)
    class HeroAdmin(admin.ModelAdmin, ExportCsvMixin):
        ...
        readonly_fields = ["father", "mother", "spouse"]
    

    reference : https://books.agiliq.com/projects/django-admin-cookbook/en/latest/changeview_readonly.html

提交回复
热议问题