11. Test project's settings.py
Since we switched back to real from virtualenv in previous chapter, we need to reactivate virtualenv:
$ pwd /home/k/Django/DjangoVirtualenv k@HP-Notebook:~/Django/DjangoVirtualenv$ source bin/activate (DjangoVirtualenv)k@HP-Notebook:~/Django/DjangoVirtualenv$
$ pwd /home/k/Django/DjangoVirtualenv $ tree -L 3
Let's look into the settings.py. Since we're going to use sqlite3 database which is the default database, we want to focus on DATABASE section:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }
NAME is the name of our database. We're using SQLite, and the database will be a file on our computer; in that case, NAME should be the full absolute path, including filename, of that file. If the file doesn't exist, it will automatically be created when we synchronize the database for the first time.
For other than sqlite3, we may need other keys such as 'USER', 'PASSWORD', 'HOST', and 'PORT'. Actually, they used be set as ' ' for sqlite3.
While we're editing settings.py, we need to set TIME_ZONE to our time zone. The default value is the Central time zone in the U.S. (Chicago).
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization