如何使heroku在运行collectstatic时自动运行compilemessages [英] How to make heroku automatically run compilemessages just as it runs collectstatic

查看:69
本文介绍了如何使heroku在运行collectstatic时自动运行compilemessages的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

python manage.py compilemessages

创建编译的翻译文件从翻译源文件名称(如 locale / en / LC_MESSAGES / django.po locale / en / LC_MESSAGES / django.mo c>。

Creates compiled translation files named like locale/en/LC_MESSAGES/django.mo from translation source files names like locale/en/LC_MESSAGES/django.po.

我想让 *。mo 文件被git忽略并且未提交到存储库,因为它们不是源文件。

I would like to have the *.mo files ignored by git and not committed to the repository, as these are not source files.

Heroku已经知道要执行

Heroku already knows to perform

python manage.py collectstatic

用于Django项目。

for django projects.

我如何使其还执行编译消息

当前,我通过以下方法解决此问题:将编译结果文件( *。mo )添加到我的存储库中,但我想知道是否有更好的方法。

Currently I work around the problem by adding the compilation result files (*.mo) to my repository but I'd like to know if there's a better way.

(如果相关-我网站的仓库: https://github.com/yairchu/vote_tool

(If relevant - the repo for my site: https://github.com/yairchu/vote_tool)

推荐答案


  1. 在项目根目录中创建文件: bin / post_compile

  2. 添加行 ./ manage.py compilemessages

  3. git push origin

  4. git push heroku

  1. Create a file in your project root: bin/post_compile
  2. Add the line ./manage.py compilemessages
  3. git push origin
  4. git push heroku

当您将分支推送到Heroku时,它现在应该运行该命令。我不确定拥有自定义的 bin / post_compile 文件是否会覆盖Heroku进行的自动检测,因此如果您发现它不再运行 collectstatic ,只需在您的 compilemessages 行下弹出该行,但将-noinput 添加到该行,以便管理命令不会提示您键入是以确认您要覆盖现有文件。

As you push your branch to Heroku, it should now run that command. I'm not certain whether having a custom bin/post_compile file will override the autodetection that Heroku does, so if you find that it's no longer running collectstatic, just pop that line in under your compilemessages line, but add --noinput to the line so that the management command doesn't prompt you to type "Yes" to confirm you want to overwrite existing files.

这篇关于如何使heroku在运行collectstatic时自动运行compilemessages的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆