What is the purpose of the DATABASES setting in Django?
The DATABASES setting tells Django where and how to connect to your database. It includes details like the database engine, name, user, password, host, and port.
Click to reveal answer
beginner
Which key in the DATABASES dictionary specifies the type of database Django will use?
The ENGINE key specifies the database type, such as django.db.backends.sqlite3 for SQLite or django.db.backends.postgresql for PostgreSQL.
Click to reveal answer
intermediate
How do you configure Django to use a PostgreSQL database?
You set ENGINE to django.db.backends.postgresql, then provide NAME, USER, PASSWORD, HOST, and PORT in the DATABASES setting.
Click to reveal answer
beginner
Why is it important to keep database credentials secure in Django settings?
Because database credentials give access to your data. If exposed, someone could read, change, or delete your data. Use environment variables or secret managers to keep them safe.
Click to reveal answer
beginner
What happens if you don't configure the DATABASES setting in Django?
Django uses a default SQLite database named db.sqlite3 in your project folder. This is good for quick tests but not for production apps.
Click to reveal answer
Which setting key defines the database type in Django's DATABASES?
ANAME
BENGINE
CUSER
DHOST
✗ Incorrect
The ENGINE key tells Django which database backend to use.
What is the default database engine Django uses if none is configured?
AMySQL
BPostgreSQL
CSQLite
DOracle
✗ Incorrect
Django defaults to SQLite with a file named db.sqlite3.
Where should you ideally store sensitive database passwords in a Django project?
AIn static files
BDirectly in <code>settings.py</code>
CIn the database itself
DIn environment variables
✗ Incorrect
Environment variables keep secrets out of code and version control.
Which of these is NOT a required key in a Django database configuration?
ATEMPLATE
BNAME
CENGINE
DPASSWORD
✗ Incorrect
TEMPLATE is not a standard key in Django's DATABASES setting.
To connect Django to a PostgreSQL database, which ENGINE value should you use?
Adjango.db.backends.postgresql
Bdjango.db.backends.sqlite3
Cdjango.db.backends.oracle
Ddjango.db.backends.mysql
✗ Incorrect
Use django.db.backends.postgresql for PostgreSQL.
Explain how to set up the DATABASES setting in Django for a new project using SQLite.
Think about the simplest database Django uses by default.
You got /4 concepts.
Describe best practices for managing database credentials securely in a Django project.
Consider how to keep secrets safe from others.
You got /4 concepts.
Practice
(1/5)
1. What is the purpose of the ENGINE setting in Django's database configuration?
easy
A. To define the path to the database file
B. To set the username for the database connection
C. To specify the type of database Django should use
D. To configure the database password
Solution
Step 1: Understand the role of ENGINE
The ENGINE setting tells Django which database backend to use, like SQLite, PostgreSQL, or MySQL.
Step 2: Differentiate from other settings
Settings like NAME, USER, and PASSWORD handle connection details, not the database type.
Final Answer:
To specify the type of database Django should use -> Option C
Quick Check:
ENGINE = database type [OK]
Hint: ENGINE always means database type, not credentials [OK]
Common Mistakes:
Confusing ENGINE with NAME or USER
Thinking ENGINE sets username or password
Assuming ENGINE is a file path
2. Which of the following is the correct way to configure a SQLite database in Django's settings.py?
Using environment variables lets you switch database settings without changing code, ideal for dev vs prod.
Step 2: Why other options fail
Always setting PostgreSQL ENGINE won't work in dev without PostgreSQL installed; changing USER alone doesn't switch DB type; Django does not auto-pick between multiple databases without explicit routing.
Final Answer:
Use environment variables to switch ENGINE and NAME based on environment -> Option A
Quick Check:
Env vars enable flexible DB config [OK]
Hint: Use env vars to switch DB settings per environment [OK]
Common Mistakes:
Hardcoding production DB in dev settings
Assuming Django auto-selects DB from multiple configs
Changing USER does not switch database type
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.