Database Setup
Introduction
This section guides you through setting up the project’s database. You can use any database supported by Django ORM, including MySQL, PostgreSQL, and SQLite. The database stores the web application’s data and is managed by Django ORM, so you don’t need to worry about migrations. Simply set up the database and enter its credentials in the project’s settings.py file.
The project uses SQLite by default. You can change the database to MySQL or PostgreSQL by following Django’s documentation.
Prerequisites
There is no need to install any additional software to set up the database with SQLite. The Django ORM comes with SQLite support out of the box.
Setup
SQLite
SQLite is a lightweight database that stores the database in a single file. It is the default database for Django and is recommended for development.
To set up SQLite, follow these steps:
Open the project’s
settings.pyfile.In the
DATABASESdictionary, change theENGINEvalue todjango.db.backends.sqlite3.Change the
NAMEvalue to the path where you want to store the database file. For example, if you want to store the database file in the project’s root directory, change theNAMEvalue toos.path.join(BASE_DIR, 'db.sqlite3').Now follow the step in the Create a database to create the database file.