django mysql settings
snippet in sql

django mysql settings


#add this settings in settings file

    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'DB_NAME',
        'USER': 'DB_USER',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',

configure mysql database django


You need to make changes in project 
Provide USER and PASSWORD for your database
If your database isn't mysql change ENGINE

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'myproject',
        'USER': 'root',
        'PASSWORD': 'rootpassword',
        'HOST': 'localhost',
        'PORT': '',

link django to mysql


$ brew reinstall openssl
	#run two commands under "For compilers to find openssl@1.1 you may need to set:"
$ pip install mysqlclient

django creating database


# --------------- Start with databases in Django ------------------ #

In your virtual environment, where your Django project lives, 
use the following commands:
  # Migrations are Django’s way of propagating changes you make to 
  # your models (adding a field, deleting a model, etc.) into your 
  # database schema.
   >> python3 makemigrations   
  # If used for the first time, it creates a standard user model 
  # (a table for saving information about users). Otherwise, it updates 
  # the database with the new information in the folder "migrations" 
  # (responsible for applying and unapplying migrations):
   >> python3 migrate 
  # For printing the SQL code that is going to run:
  >> python3 sqlmigrate "name_app" "code_of_specific_object"  
  # for example: python3 sqlmigrate app 0001
  # Run a Django + python shell for working/testing with models:
  >> python3 shell