Question

I’m running a Django app on Heroku and have installed this piece of code: https://github.com/st4lk/django-solid-i18n-urls

It works just as expected on the Django built-in server, but when deployed to Heroku, I’m starting to see some really nasty problems.

I have Gunicorn running with multiple workers and if I use this code, the language preference starts to work randomly (I guess it depends which instance the request goes against).

For example if I have EN as the default (non-prefixed url) and DE as the second language, everything is working fine if I just browse the / urls. Now, if I switch to /de/ (manually enter URL or switch from the Django language switcher), the main / url starts to work intermittently – if I keep refreshing the page, I get either a 404 or the page in DE. But there’s no way to switch it back to using EN completely again. Same happens with all the other URLs as well, I get either a 404 or the corresponding page in DE. And there’s no way to force it back to EN, even from the Django’s set_language view.

If I never touch the /de/ urls, it works all very well without the prefixed URLs.

Does anyone have any ideas how to get this working also on Heroku and Gunicorn?

Was it helpful?

Solution

It turns out Gunicorn and the middleware override works fine, problem was with another piece of custom middleware.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top