[Django]-Django Admin: Alter how data is displayed

3👍

Answering my own question…

After reading the documentation near what Matthew J Morrison pointed me to. I discovered I could add a javascript to alter things.

to my ModelAdmin I added

class Media:
    js = ("/site_media/json2.js", "/site_media/custom.js")

json2.js is from Douglas Crockford’s website

custom.js is

django.jQuery(document).ready(function() {
    data = JSON.parse(django.jQuery("#id_json")[0].value);
    django.jQuery("#id_json")[0].value = JSON.stringify(data, null, 4)
});

Easy when you know how.

1👍

Leave a comment