Inline Crud Example


#1

@limedaring I have an off “book” question…more so advice on proper search terms so I can find my own answer. I am creating a reporting app for use by my online marketing department and need a CRUD example that does all operations inside a single template.

For example, I have the typical traffic_form.html, traffic_list.html and traffic_confirm_delete.html. Currently I would go to traffic_form.html and add a new record, which would then take me to the traffic_list.html page and if I wanted to delete a record, I would click ‘delete’ … yadda yadda yadda … normal crud stuff. It works as it should - the problem is, its horribly inefficiency as we deal with thousands of rows of data and moving between views isn’t going to work for us.

My list page is in table format and has a function that aggregates the sum of the columns. What I would like is to add a column on the right with three icons, one for add, one for edit and one for delete. But, instead of normal moving between templates, I would like a new row to open within my table that I can add additional data and save directly and if I hit edit, it would make the row editable and of course, if I hit delete, the row would delete inline and on the same page.

So basically, have all the crud operations run efficiently on the same template.

Any help guiding me to a solution would be great appreciated :) Thank you.


#2

Totally doable — you can tie in AJAX-y Javascript so it pings your views and grabs the returned data, but to the user, it looks like everything is done without switching pages.

Maybe this helps? https://realpython.com/blog/python/django-and-ajax-form-submissions/


#3

This was perfect…great find! What did you say on one of your responses - Yeah, TIL!! :)