开发者

Showing Django Admin actions on template

I'm currently building a dashboard for my project and I would like th开发者_如何转开发e 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜