如何禁用“最近的操作” Django管理界面中的窗口小部件? [英] How can I disable the "Recent Actions" widget from Django Admin interface?
问题描述
我不想在Django管理网站中显示最近操作小部件。我不知道如何完成此操作。
I dont want to show the recent action widget in django admin site.I don't know how to get this done.
推荐答案
,您可以覆盖 admin / index.html
模板以禁用显示。您可能需要更改/删除一个
的侧边栏块。
you can override the admin/index.html
template to disable the display. There's
a sidebar block you might want to change/remove.
有条件地启用或禁用操作
ModelAdmin.get_actions(request)
最后,您可以有条件地对每个请求启用或禁用操作(和
Conditionally enabling or disabling actions ModelAdmin.get_actions(request) Finally, you can conditionally enable or disable actions on a per-request (and hence per-user basis) by overriding ModelAdmin.get_actions().
这将返回允许的操作字典。键是动作名称,值是(函数,名称,short_description)元组。
This returns a dictionary of actions allowed. The keys are action names, and the values are (function, name, short_description) tuples.
大多数时候,您将使用此方法有条件地从由超类收集的列表。例如,如果我只希望名称以'J'开头的用户能够批量删除对象,则可以执行以下操作:
Most of the time you'll use this method to conditionally remove actions from the list gathered by the superclass. For example, if I only wanted users whose names begin with 'J' to be able to delete objects in bulk, I could do the following:
class MyModelAdmin(admin.ModelAdmin):
...
def get_actions(self, request):
actions = super(MyModelAdmin, self).get_actions(request)
if request.user.username[0].upper() != 'J':
del actions['delete_selected']
return actions
我编辑了答案,您可能会在 https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/
i edited the answer you may find more like this at https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/
这篇关于如何禁用“最近的操作” Django管理界面中的窗口小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!