Readonly models in Django admin interface?

前端 未结 14 1537
北恋
北恋 2020-12-02 05:53

How can I make a model completely read-only in the admin interface? It\'s for a kind of log table, where I\'m using the admin features to search, sort, filter etc, but there

14条回答
  •  一生所求
    2020-12-02 06:18

    This was added in to Django 2.1 which was released on 8/1/18!

    ModelAdmin.has_view_permission() is just like the existing has_delete_permission, has_change_permission and has_add_permission. You can read about it in the docs here

    From the release notes:

    This allows giving users read-only access to models in the admin. ModelAdmin.has_view_permission() is new. The implementation is backwards compatible in that there isn’t a need to assign the “view” permission to allow users who have the “change” permission to edit objects.

提交回复
热议问题