简体   繁体   中英

DataTable Editor with django backend for inline edit

I am trying to implement a data table editor with django backend for inline editing.

I am not able to get the updated values in my django views while performing the edit operation in the data table.

I console the data inside the 'preSubmit' method of data table editor and its working fine as I expected.

  editor.on( 'preSubmit', function ( e, data, action ) {
        console.log(data)

    }
 )

Here is the console output .

{action: "edit", data: {19054002: {description: "Orion ChocoPie 560gm"}},
table_name: "rp_p_m"}

But the problem is while fetching all the keys in django view I am not getting all the keys as I expect which are

['action', 'data', 'table_name'].

Code Inside views.py

def product_master(request):
    keys = []
    for key in request.POST:
        keys.append(key)

    print(keys)

Instead, I am getting the output like this

['action', 'data[19054002][description]', 'table_name']

All the nested keys get combined with the key 'data'.

If this is still actual you can try https://github.com/VVyacheslav/django-rest-framework-datatables-editor

This project implements seamless integration between Django REST framework, Datatables and Datatables Editor. You just need to install it with pip:

$ pip install djangorestframework-datatables-editor

Make some changes to settings.py and use DatatablesEditorModelViewSet instead ModelViewSet or add EditorModelMixin to your views.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM