开发者

how to add ajax onto django admin

开发者 https://www.devze.com 2023-01-11 04:21 出处:网络
I\'d like to make some aspects of django admin interface a bit more fluid without refreshes. For example, I have this ReportAdmin(admin.ModelAdmin) class, which has a list_editable property that wil

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

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


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


is it possible to use ajax to save the entire form instead? Just keep a list of changes and save only the intended change

Admin uses formsets to display dtata in multiple forms and formset.save() checks for formset.changed_forms before saving. So, only necessary db writes happen. Not every db entry is re-written.


Old question, but I found it when googling. Try https://github.com/sjrd/django-ajax-selects

0

精彩评论

暂无评论...
验证码 换一张
取 消