Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make heroku automatically run compilemessages just as it runs collectstatic

Tags:

django

heroku

python manage.py compilemessages

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

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

Heroku already knows to perform

python manage.py collectstatic

for django projects.

How do I make it also perform compile messages?

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.

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

like image 781
yairchu Avatar asked Feb 03 '15 20:02

yairchu


People also ask

Does Heroku serve static files?

You should store them externally on a service like S3 - while Heroku can serve static files, it's not designed to.

What is Django_heroku?

Project description This is a Django library for Heroku applications that ensures a seamless deployment and development experience.


1 Answers

  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

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.

like image 67
Steadman Avatar answered Dec 31 '22 18:12

Steadman