how to create database in django code example
Example 1: configure mysql database django
You need to make changes in project settings.py.
Provide USER and PASSWORD for your database
If your database isn't mysql change ENGINE
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'USER': 'root',
'PASSWORD': 'rootpassword',
'HOST': 'localhost',
'PORT': '',
}
}
Example 2: database setup in django
sudo apt install python3-dev libmysqlclient-dev default-libmysqlclient-dev
Example 3: django creating database
In your virtual environment, where your Django project lives,
use the following commands:
>> python3 manage.py makemigrations
>> python3 manage.py migrate
>> python3 manage.py sqlmigrate "name_app" "code_of_specific_object"
>> python3 manage.py shell