I've a small django mezzanine application in https://github.com/miettinj/mezzanine It translates admin interface correctly, but it also should translate the page history to understandable form. (I guess it comes directly from django_admin_log in database)
Now the admin log looks like this:
{
"model": "admin.logentry",
"pk": 2,
"fields": {
"action_time": "2022-11-18T08:34:03.136Z",
"user": 1,
"content_type": 18,
"object_id": "1",
"object_repr": "janes post",
"action_flag": 2,
"change_message": "[{\"changed\": {\"fields\": [\"Content\", \"Keywords\"]}}]"
}
}
How can I change it so that it translates the action 'changed', remains the field names unchanged and totally removes the unuserfrienly characters: ("[{\) ?
In the attachment the lines surrounded with blue are correct and lines surrounded with read are current functionality.
Might be coming late to the game but I had the same question recently.
First of all, you first show a json (which is also a dict in python) which can easily be parsed in python:
This can be parsed in python to keep only the "change_message" field either by considering it as json representation (JSON double parsing) or a dictionary representation:
Dict:
With the output being: [{"changed": {"fields": ["Content", "Keywords"]}}]
JSON
With the output being [{"changed": {"fields": ["Content", "Keywords"]}}]
Final Parsing
Now, either you take the whole JSON file and then you parse it to take the "change_message" or you take directly the "change_message" from the LogEntry, then you will need to further parse it and define the display that you want. You can do for example:
With the output being: Changed: Content, Keywords