Django,扩展管理员的模板标签

发布于 2024-09-25 06:27:38 字数 516 浏览 2 评论 0原文

我想向 django 管理添加一个模板标签,如何扩展现有标签而不需要在 django.contrib.admin.templatetags 中进行修改?

更新:

在管理模板中使用 {% load mytemplatetags %} 由于某种原因破坏了我的服务器(我使用 nginx 并为该页面抛出了一个错误的网关)。但文件 mytemplatetags.py 确实存在于我的应用程序的 templatetags 模块中。

有趣的是,当我拼写错误或为其应用一个不存在的名称时,例如说 {% load footemplatetags %} 它只会给我一个普通的 django 错误:

'footemplatetags' is not a valid tag library

所以它可能知道 mytemplatetags.py 的存在,但不知道如何处理它。

我正在使用 django 1.3 alpha(刚刚检查了 svn),也许使用稳定的东西是个好主意?

I want to add an templatetag to the django admin, how can I go around extending the existing tags without needing to fudge in django.contrib.admin.templatetags?

Update:

Using {% load mytemplatetags %} in the admin templates breaks my server for some reason (im using nginx and throws me a bad gateway for that page). But the file mytemplatetags.py does exist in the templatetags module of my app.

Interestingly enough when I just misspell or apply a non-existing name for it, forinstance say {% load footemplatetags %} it just gives me an ordinary django error:

'footemplatetags' is not a valid tag library

So it probably knows mytemplatetags.py's existance, but doens't know how to handle it.

I am using django 1.3 alpha (just checked out the svn), perhaps its a good idea to get with something stable?

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

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

发布评论

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

评论(1

白衬杉格子梦 2024-10-02 06:27:38

没关系,我的模板标签坏了。

Nevermind, my template tag was broken.

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