1👍
You can use a local.py
file in your settings module that is unique for the environment you’re working on. Given a settings module, you can put the following in your __init__.py
:
try:
import .local
except ImportError:
pass
Then on the machine where the Oracle database is available, set the right settings in the local settings file, but don’t check it in to your version control system (e.g. put it in .gitignore
).
Also watch for the order in your settings, after you import your local settings, you shouldn’t override them if you want to keep the changes. You can move the import down in the file, or just add the settings to the existing dict.
0👍
You can use if
statements in your settings.py
, since it’s just a Python script. So you can add a function to detect whether you are at work, and then use that function to decide whether the at work-only database should be added to the DATABASES
variable.
# in settings.py
def at_work():
'Determines whether the project runs at work'
if at_work():
DATABASES = {...}
else:
DATABASES = {...}
Of course, if your models depend on the database that is only available at work, you will need to add a mock database to enable use of the models elsewhere, even if there is no data available.
- [Answer]-Converting non-ASCII characters using slugify
- [Answer]-Realistic data generator package available for Django