如何添加ajax到django管理员 [英] how to add ajax onto django admin

查看:142
本文介绍了如何添加ajax到django管理员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让django管理界面的某些方面更加流畅,无需刷新。

I'd like to make some aspects of django admin interface a bit more fluid without refreshes.

例如,我有这个ReportAdmin(admin.ModelAdmin)类,它有一个list_editable属性,允许用户在报表视图列表中编辑特定的字段而不是点击每个报告并在那里进行编辑。但是,我想在每个编辑的字段下面都有一个按钮,这样当用户完成编辑特定的单元格时,他只需点击该按钮即可使用ajax来保存该单元格(如果不可能,可以使用ajax来保存整个表单代替?只需保留更改列表,只保存预期的更改)。

For example, I have this ReportAdmin(admin.ModelAdmin) class, which has a list_editable property that will allow user to edit the specific fields right on the list of reports view rather than clicking into each report and edit it there. However, i'd like a button under each edited field such that when the user finishes editing a particular cell, he can just click on that button to use ajax to save that cell (if not possible, is it possible to use ajax to save the entire form instead? Just keep a list of changes and save only the intended change).

如果任何人有任何想法/资源如何完成这一点,将不胜感激!

If anyone have any idea/resources on how to accomplish this, it would be much appreciated!

Jason

推荐答案

您可以使用媒体类。在那里,您可以定义通过Ajax提交更改的功能。

You can add JS code to Admin objects using its Media class. There you can probably define functions to submit changes through Ajax.

这篇关于如何添加ajax到django管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆