Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing Django Admin actions on template

I'm currently building a dashboard for my project and I would like the admin or super user to be able to see all the actions that have been down so far, sort of like an activity log.

For example:

User A has created a new project object

Is there any way to pull the django admin actions and place them on a template (my dashboard.html)?

If anyone could at least point me in the right direction that would be a great help.

Thanks,

Steve

like image 677
TheLifeOfSteve Avatar asked Jan 31 '26 01:01

TheLifeOfSteve


1 Answers

URLs:

(r'^dashboard$', 'dashboard_view'),

View:

from django.contrib.admin.models import LogEntry
def dashboard_view(request):
    log = LogEntry.objects.select_related().all().order_by("id")
    return render_to_response("app_name/dashboard.html", {'log': log},)

Template:

{% for l in log %}
<p>
    {{ l.id }} {{ l.user.username }} {{ l.change_message }}
</p>

{% endfor %}

There's an extension django-reversion it allows to keep track of all changes made to models not only actions in admin interface. It also allows to rollback the model to any point in time.

like image 185
Alex McGunn Avatar answered Feb 02 '26 17:02

Alex McGunn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!