如何将非CRUD操作添加到django管理员

时间:2021-09-03 07:23:42

I need to create a simple CRUD interface for my Django app. The Django admin does 90% of what I need, but I have a couple of things that don't fit well.

我需要为我的Django应用程序创建一个简单的CRUD界面。 Django管理员做了我需要的90%,但我有一些不太合适的事情。

Say I have a File model and a Validator model. Besides CRUDing them, I also need to be able to send a File to a Validator for validation. This is not a database action. Sending a file to a validator involves scheduling the file on the validators queue. Later (minutes or hours), when the validator completes, that fact will be noted in the database.

假设我有一个File模型和一个Validator模型。除了CRUD他们之外,我还需要能够将文件发送到验证器进行验证。这不是数据库操作。将文件发送到验证器涉及在验证器队列上调度文件。稍后(分钟或小时),当验证器完成时,将在数据库中记录该事实。

From a UX view, this naturally belongs on the File admin page as a dropdown to select a validator and a button. Is there a way to naturally add this to the admin?

在UX视图中,这自然属于文件管理页面,作为选择验证器和按钮的下拉列表。有没有办法自然地将此添加到管理员?

(I am a django newbie, I apologize if this is a stupid question.)

(我是django新手,如果这是一个愚蠢的问题,我道歉。)

1 个解决方案

#1


1  

This is a very general question. The admin allows you to extend it in almost any way you wish. I would personally start by looking at how to create packages (apps) in Django.

这是一个非常普遍的问题。管理员允许您以几乎任何方式扩展它。我个人首先看看如何在Django中创建包(app)。

You can extend the admin in many ways, admin actions, other apps, custom dashboard to overwriting templates etc just to name a few.

您可以通过多种方式扩展管理员,管理员操作,其他应用程序,自定义仪表板以覆盖模板等等,仅举几例。

There are also a lot of packages that already achieve this too.

还有很多软件包已经实现了这一目标。

For task processing of the file look at Celery. Celery is an asynchronous task queue/job queue system.

有关文件的任务处理,请查看Celery。 Celery是一个异步任务队列/作业队列系统。

More reading: Customizing Django Admin Interface functionality

更多阅读:自定义Django管理界面功能

#1


1  

This is a very general question. The admin allows you to extend it in almost any way you wish. I would personally start by looking at how to create packages (apps) in Django.

这是一个非常普遍的问题。管理员允许您以几乎任何方式扩展它。我个人首先看看如何在Django中创建包(app)。

You can extend the admin in many ways, admin actions, other apps, custom dashboard to overwriting templates etc just to name a few.

您可以通过多种方式扩展管理员,管理员操作,其他应用程序,自定义仪表板以覆盖模板等等,仅举几例。

There are also a lot of packages that already achieve this too.

还有很多软件包已经实现了这一目标。

For task processing of the file look at Celery. Celery is an asynchronous task queue/job queue system.

有关文件的任务处理,请查看Celery。 Celery是一个异步任务队列/作业队列系统。

More reading: Customizing Django Admin Interface functionality

更多阅读:自定义Django管理界面功能