Django -Gunicorn not serving internationalized app -throwing 'Internal Server Error: /ja/ ' and "KeyError: 'translate' "

My Django app uses internationalization to support English and Japanese languages with Japanese being the default language. The language codes are appended to the app's URLs so all of my URLs either look like this

http://127.0.0.1:8000/ja/

or like this

http://127.0.0.1:8000/en/

If you navigate to http://127.0.0.1:8000 , my urls.py config automatically appends '/ja/' to the the URL and redirects to http://127.0.0.1:8000/ja/ which I suspect may be a problem but I am not sure.

I also have {% translate ' ' %} tags all over the place in my templates for internationalization.

Everything works perfectly while running Django's built in server. When I execute this command in the terminal:

'gunicorn Main_Project.wsgi'

it seems to run and successfully listen to http://127.0.0.1:8000 which is the same ip address that django's runserver command listens to.

But when I navigate to http://127.0.0.1:8000, in the terminal where Gunicorn is running I am getting an "Internal Server Error: /ja/" and a 'KeyError: 'translate''

This is the line in the code that Gunicorn is complaining about:

<a href="/{{LANGUAGE_CODE}}/account/myaccount/" title="My Account">{% translate "アカウント" %}</a>

But this line works perfectly when running python manage.py runserver, so I am 100% sure there are no syntax errors. So the only thing I can think of is that I am doing something ignorantly with Gunicorn's configuration and so I come to you to help diagnose the problem. Any tips or advice will be greatly appreciated.

Thank you!

Back to Top