在模板上显示 Django 管理员操作

发布于 2024-11-02 10:50:55 字数 209 浏览 4 评论 0原文

我目前正在为我的项目构建一个仪表板,我希望管理员或超级用户能够查看到目前为止已关闭的所有操作,有点像活动日志。

例如:

用户 A 创建了一个新的项目对象

有没有办法拉取 django 管理操作并将它们放在模板上(我的仪表板.html)?

如果有人至少能指出我正确的方向,那将是一个很大的帮助。

谢谢,

史蒂夫

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两个我 2024-11-09 10:50:55

URLs:

(r'^dashboard

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 %}

有一个扩展 django-reversion 它允许跟踪对模型所做的所有更改,而不仅仅是管理界面中的操作。它还允许将模型回滚到任何时间点。

, 'dashboard_view'),

View:

Template:

有一个扩展 django-reversion 它允许跟踪对模型所做的所有更改,而不仅仅是管理界面中的操作。它还允许将模型回滚到任何时间点。

URLs:

(r'^dashboard

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.

, 'dashboard_view'),

View:

Template:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文