[英]Use request / user in django admin template
I'm trying to access the user / request variables in django admin templates. 我正在尝试访问Django管理模板中的用户/请求变量。
Specifically, I'd like to add new submit buttons depending on the user role. 具体来说,我想根据用户角色添加新的提交按钮。 I've copied submit_line.html in my project template folder, but calling {{user}} or {{request}} don't display anything.
我已经在项目模板文件夹中复制了commit_line.html,但是调用{{user}}或{{request}}不会显示任何内容。
I've already added the following in my settings file. 我已经在设置文件中添加了以下内容。
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
)
Did I miss something? 我错过了什么?
Alternatively, is there a standard way to add submit buttons besides editing submit_line.html? 另外,除了编辑submit_line.html之外,是否还有一种添加提交按钮的标准方法?
If you read the code for the submit_row
templatetag (the one that renders submit_line.html
), you'll notice that the original context is not passed to the submit_line.html
template. 如果您阅读了
submit_row
templatetag的代码(呈现submit_line.html
),则会注意到原始上下文未传递到submit_line.html
模板。
I'm afraid your best bet will be to replace the submit_row
templatetag with something of your own, and override the admin/change_form.html
template to call your own templatetag instead. 恐怕您最好的选择是用自己的东西替换
submit_row
templatetag,并覆盖admin/change_form.html
模板来调用您自己的templatetag。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.