In the development environment, I set locale paths to:
LOCALE_PATHS = (
'/Users/***/Documents/Projects/**/Server/Django/**/locale',
)
But when I deploy it to server, locale path shold be changed.
How can I handle this?
to settings add
import os
LOCALE_PATHS = (
os.path.join(os.path.dirname(__file__), "locale"),
)
I am still currently using Django 1.5 and have found that I can handle it the easiest with the following:
LOCALE_PATHS = (
'locale',
)
The following works better if you need to use an absolute path (indentation emphasized on purpose):
import os.path
LOCALE_PATHS = (
os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'..', "locale")),
)
os.path.dirname
returns the path to the directory of the settings file (__file__
), e.g. /Users/foobar/projects/django-tutorial/mysite/mysite
os.path.join
joins the previous result with a relative reference to a locale
directory one level higher, e.g. /Users/foobar/projects/django-tutorial/mysite/mysite/../locale
os.path.abspath
transforms the previous relative path reference to an absolute one, e.g. /Users/foobar/projects/django-tutorial/mysite/locale
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With