How to get all field details in a django LogEntry()

1.1k views Asked by At

I have a LogEntry items I'dlike to call one by one to make a table. So far I have managed to get it working partially with this.

<table class="layout">
  <thead>
    <th>User</th>
    <th>Date</th>
    <th>Log</th>
    <th>Item Affected</th>
    <th>Item ID</th>
  </thead>
  {% for log in logs %}
    <tr>
      <td>{{ log.user}} - {{ log.user_id }}</td>
      <td>{{ log.action_time|date:"d/m/Y - g:ia" }}</td>
      <td>{{ log }}</td>
      <td>{{ log.object_repr }}</td>
      <td>{{ log.object_id }}</td>
      <td>{{ log.change_message }}</td>
    </tr>
  {% endfor %}

</table>

<td>{{ log.change_message }}</td> Gives me data in this format.

[{"changed": {"fields": ["Borrower id"]}}]

When I try

{% for log in logs %}
    {{ log }}
{% endfor %}

I get data in this format. Changed “Smart Maths:-MAT/1663/21” — Changed Borrower id. What would I call in my template in order to get this last part only???? Changed Borrower id

This is my view

def admin_main(request,object=Issue):
    LogEntry.objects.log_action(
        user_id=request.user.id,
        content_type_id=ContentType.objects.get_for_model(Issue).pk,
        object_repr=str(object.book_id),
        object_id=object.id,
        change_message="Items added",
        action_flag=ADDITION)
    logs = LogEntry.objects.exclude(object_id__icontains='django.db.').exclude(object_id__icontains = 'property object').order_by('-action_time')[:40]

    return render(request,'libman/returns_history.html', {"logs":logs})
0

There are 0 answers