Editor - Client/Server data - Django, no PHP

Editor - Client/Server data - Django, no PHP

carstenthiescarstenthies Posts: 2Questions: 1Answers: 1

Hello,
I implemented DataTables in a Django project and it is working great.
When I went on to implementing Editor I realized that there is no library for Django/Python.
I started to implement my own Python code to take of the ajax call to create a new record in a table.
I receive the data from the client as described in the Editor manual on the 'Client/Server data' page.
I can create the new record in the database. I then create a JSON response in line with the example from the manual.
My problem is that the datatable in the UI does not get updated with the newly created record.

My page is accessible here: http://www.soukarabia.com/databrowser
If you get a 502 'Bad Gateway', just refresh the browser page.

To create a new record you can use any of the following values combinations:
10 and 74
10 and 84
10 and 89
10 and 94
10 and 104
14 and 74
14 and 84

Edit and delete has not yet been implemented.

Please help.

This question has accepted answers - jump to:

Answers

  • carstenthiescarstenthies Posts: 2Questions: 1Answers: 1
    Answer ✓

    Ok, quick update, I found my mistake...
    In the django view I was doing the return like this:
    return JsonResponse({'invitems': serverreturn}, safe=False)
    resulting in a response as follows:
    {"invitems": {"data": [{"DT_RowId": "row_132", "menuid": "10", "userid": "49"}]}}

    So I changed how I compose the serverreturn and change the return line to the following:
    return JsonResponse({'data': serverreturn}, safe=False)

    The key here is to use 'data' as the name for the return data.
    I had one more error but that was just due to a missing field.

    All good now, on to the next one.
    Thanks to everyone who took the time to view and read.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Nice one - thanks for posting back. Just to let you know, you can use the ajax.dataSrc option to change the default data property to something else (such as invitems) if you wanted.

    Allan

Sign In or Register to comment.