简体   繁体   English

如何在Django管理面板中添加自定义视图和操作?

[英]How to add custom view and actions to django admin panel?

I'm new at Python and Django development. 我是Python和Django开发的新手。 I'm trying to make a simple blog. 我正在尝试制作一个简单的博客。

Right now what i am trying to do is create a admin function to show comments that not approved by admin yet. 现在,我正在尝试创建一个admin功能,以显示尚未得到admin批准的评论。 I like to show that comments and offer accept or reject choices to admin. 我想表明评论并提供接受或拒绝管理员的选择。

The problem is, i don't know the steps. 问题是,我不知道步骤。 I made some searches online but couldn't find what we are looking for. 我在网上做了一些搜索,但是找不到我们想要的东西。 What are the steps to do this? 有哪些步骤可以做到这一点? What i need to learn to do this? 我需要学习些什么?

How do i add add custom list, buttons and functionality? 如何添加添加自定义列表,按钮和功能? I don't event know where to write code for my custom admin functionality. 我不知道该为我的自定义管理员功能编写代码。

Ps: I'm not looking for someone to write code for me. 附言:我不是在找别人为我编写代码。 I'm just looking for guidelines. 我只是在寻找准则。

I recommend using django-admin-plus ( https://github.com/jsocol/django-adminplus ) which does exactly what you want: 我建议使用django-admin-plus( https://github.com/jsocol/django-adminplus ),它完全可以满足您的需求:

AdminPlus aims to be the smallest possible extension to the excellent Django admin component that lets you add admin views that are not tied to models. AdminPlus的目标是对出色的Django管理组件进行最小的扩展,使您可以添加不依赖于模型的管理视图。

All AdminPlus does is allow you to add simple custom views (well, they can be as complex as you like!) without mucking about with hijacking URLs, and providing links to them right in the admin index. AdminPlus所做的全部工作就是允许您添加简单的自定义视图(好吧,它们可以随您的喜欢!),而不必嘲笑劫持URL,并在admin索引中提供指向它们的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM