Mako 模板使用旧版本,直到我手动更新模板文件

发布于 2024-08-16 00:49:17 字数 162 浏览 2 评论 0原文

我定期遇到这个问题,mako 突然使用旧版本的模板,直到我手动去更新模板文件,他们才会使用当前版本。我正在使用,

./manage.py runserver

我认为这通常是在使用源代码管理更新之后,但它是间歇性的,并且我无法可靠地重现该问题。

I periodically get this problem where all of a sudden mako is using old versions of templates, and it's not until I manually go and update the template files that they'll use the current version. I'm using

./manage.py runserver

I think it's usually after I update using source control, but it's intermittent, and I can't reliably reproduce the problem.

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

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

发布评论

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

评论(2

墨洒年华 2024-08-23 00:49:17

感觉好像正在进行一些缓存。您没有对该过程进行非常具体的描述,因此很难进行更深入的描述。

It kinda feels like there some caching going on. You don't give a very specific description of the process, so it's hard to go any deeper than that.

情何以堪。 2024-08-23 00:49:17

在 settings.py 文件中,您可以使用 MAKO_TEMPLATE_OPTS 设置来指定临时编译模板的位置。

import os
import tempfile
MAKO_TEMPLATE_OPTS=dict(input_encoding='utf-8',
                        module_directory=os.path.join(
    tempfile.gettempdir(),
    os.environ.get('LOGNAME', 'unknown_user'),
    'mako'))

这会将它们放在 /tmp/dsmith/mako 之类的地方。

您可以为不同的项目使用不同的文件夹,以确保它们不会重叠。另外,如果您在源代码管理更新或其他操作后发现问题,您可以清除缓存的文件夹。

In your settings.py file you can use the MAKO_TEMPLATE_OPTS setting to specify where the temporary compiled templates go.

import os
import tempfile
MAKO_TEMPLATE_OPTS=dict(input_encoding='utf-8',
                        module_directory=os.path.join(
    tempfile.gettempdir(),
    os.environ.get('LOGNAME', 'unknown_user'),
    'mako'))

This will put them somewhere like /tmp/dsmith/mako

You can use different folders for different projects to make sure they don't overlap. Also, if you notice the problem after a source control update or something you can just clear out the cached folder.

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