Q:

Serialize an object in django not a model

I want to serialize an object but this object not a model it just a regular class. How can I do it
class Test:
    foo = []
    bar = 1
    a = tt()
class tt
    a = "Test"

A:

Are you sure you want this to be objects at all? Looks like it would be better as a nested dict:
{
    'foo': [],
    'bar': 1,
    'a': {
        'a': 'Test'
    }
}

This of course is directly serializable to JSON via json.dumps().

