- Activate the virtual environment:
source your_virtual_environment/bin/activate
- Install the database driver for the desired database. For example, for PostgreSQL:
pip install psycopg2
- Update the Django project settings to use the desired database engine and connection parameters. Modify the
DATABASES
setting in your settings.py
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'your_database_name',
'USER': 'your_database_user',
'PASSWORD': 'your_database_password',
'HOST': 'your_database_host',
'PORT': 'your_database_port',
}
}
- Create a migration for the initial database schema:
python manage.py makemigrations
- Apply the initial migration to create the database tables:
python manage.py migrate
- Optionally, create a superuser for the admin interface:
python manage.py createsuperuser
- Start the development server:
python manage.py runserver