Django add / remove form without multiple submit

前端 未结 3 792
旧巷少年郎
旧巷少年郎 2021-01-15 00:01

I want a simple edit / remove form in Django.

I want it to look like:

Item A   edit  /   remove
Item B   edit  /   remove
Item C   edit  /   remove
<         


        
3条回答
  •  借酒劲吻你
    2021-01-15 00:24

    I did something like this for a similar problem: put this javascript in your template:

    
    

    use your template to create this delete hyperlink for each item:

    Delete
    

    put this hidden form somewhere on your page:

    '

    basically, each item will have a delete hyperlink which calls the js submit function and passes the item to delete. The js function submit sets a hidden input value to this item, then submits the form with that input thereby passing the value via POST to the url /view_to_handle_delete/, and there you handle it like a normal post request. Here the item_id will be called item_to_delete.

提交回复
热议问题