Skip to main content

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:

  1. Open the project’s settings.py file.

  2. In the DATABASES dictionary, change the ENGINE value to django.db.backends.sqlite3.

  3. Change the NAME value 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 the NAME value to os.path.join(BASE_DIR, 'db.sqlite3').

  4. Now follow the step in the Create a database to create the database file.