0
0
Djangoframework~5 mins

Database configuration in Django - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
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
What is the default database engine Django uses if none is configured?
AMySQL
BPostgreSQL
CSQLite
DOracle
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
Which of these is NOT a required key in a Django database configuration?
ATEMPLATE
BNAME
CENGINE
DPASSWORD
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
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.