I’m working with Django project on Linux and Windows. So I’m trying to config ‘settings.py’ to work on both platforms.
I can config the template dirs as:
TEMPLATE_DIRS = (
'c:/artefacts/workspace/BookMixToFb2/src/templates',
'/home/demas/workspace/BookMixToFb2/src/templates'
)
and this will be work on linux and windows.
But when I setup a database connection I have only one possibility to set way to the database file:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
#'NAME': 'C:\\Users\\ademidov.GMCS\\workspace\\BookMixToFb2\\sqlite.db', # Or path to database file if using sqlite3.
'NAME': '/home/demas/workspace/BookMixToFb2/sqlite.db', # Or path to database file if using sqlite3.
Is there any way to set two different paths to database file and pass the current path as command line argument?
Yes, you should use this tip: Use os.path.dirname() in settings.py to avoid hardcoded dirnames.