I am running Django 1.5.1 and Python 2.7, along with D3.js v3.
I have created a GUI where a user can dynamically add / delete nodes from a D3.js collapsable indented tree (like this block, but with buttons for add / remove). This all works fine on the browser side.
However, I would now like to save the user's changes into my database, via Django / Python. Is it possible to "export" my data from d3 and pass it to a Django view? From the documentation, it seems no, or at least I didn't see any command for it. I have tried to do a simple POST using Ajax, but the problem is that d3.selectAll returns objects...which are slightly recursive and cause my browser's stack to overflow. Example code is here:
var nodes = d3.selectAll('g.node');
var root_node = nodes[0][0].__data__;
var children = root_node.children;
$.ajax({
    type: "POST",
    url: "update_map/",
    data: {
        'children': children,
        'bank': obj_bank_id
    },
    success: function( result ) {
        if (result == true) {
            lscache.set( 'canvas_clean', 'true' );
        } else {
            alert( 'Error in saving data' );
        }
    },
    error: function( xhr, status, error ){
        alert( error );
    }
});
The issue I see (using Chrome's developer tools) is that 'children' is essentially infinitely long--it is an array of objects, but within each object is a "parent" object that includes all of its children, etc. ad inifinitum. A chunk is below:
Object {source: "", item_class: "root", name: "Topics", children: Array[76], x0: 0…}
children: Array[76]
    0: Object
        _children: Array[0]
        bank: "objectivebank"
        children: null
        depth: 1
        id: 2
        item_class: "objective"
        item_id: "objective"
        name: "Antiderivative"
        parent: Object
            children: Array[76]
            depth: 0
So is there a way to get a "flat" view of all the nodes without d3 metadata either using built-in d3.js commands, or some other way? I would like something cleaner, but do I just have to save things in a separate object? Thanks!
