Alejandro Veintimilla
Alejandro Veintimilla

Reputation: 11543

Django. Print all admin actions.

Someone in my team deleted an important object. I need to know who did it, he obviously had access to the admin. Is there a way I can print to the terminal (or anywhere) all the admin actions of the last 3 hours? I'm sure django keeps a history, I just don't know where to find it.

Upvotes: 0

Views: 643

Answers (1)

Alejandro Veintimilla
Alejandro Veintimilla

Reputation: 11543

This solved it:

>>> from django.contrib.admin.models import LogEntry
>>> x = LogEntry.objects.all().order_by("-id")[:200]
>>> for y in x:
...   print("%s - %s" % (y.action_time, y.change_message)) 

Upvotes: 1

Related Questions