Django + MySQL settings

Postscript 2019/10/29

It's a mystery that this article is still being read, but I wrote the following blog article before, so please read this

Let's stop using PyMySQL with Django

setup

$ pip install PyMySQL django
$ django-admin.py startproject <project_name>
$ django-admin.py startapp <app_name>

MySQL connection settings in settings.py

<project_name>/settings.py


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'dbname',
        'USER': 'dbuser',
        'PASSWORD': 'password',
        'HOST': '',
        'PORT': '',
    }
}

Set manage.py to use MySQL

manage.py


import pymysql
pymysql.install_as_MySQLdb()

Final setup

$ python manage.py makemigrations
$ python manage.py migrate
$ python manage.py createsuperuser
$ python manage.py runserver

Recommended Posts

Django + MySQL settings
django default settings
Django URL settings
Django command completion settings
Use MySQL with Django
Django Getting Started: 4_MySQL Integration
Django
DEBUG settings when using Django
django timezone and language settings
Use Unicode 6.0 emoji with django / MySQL
Consider the description of Dockerfile (Django + MySQL②)
django update
Django note 4
DJango Memo: From the beginning (model settings)
Django memorandum
django search
Django installation
WEB application development using Django [Initial settings]
Django Summary
Django # 2 (template)
Django Note 5
DB settings when using Django + SQLAlchemy + Alembic
Django hands-on
Touch django
django notes
Django basics
Django: Implement reusable APP settings following Django RestFrameWork
Django Shoho
Django defaults
Django Glossary
Django search
Install Django
Django Project HTTPS Server Settings: Let's Encrypt
Django: References
VIM settings
[Django] Settings for sending emails using postfix
Django Note 1
Django note 3
Django note 2
Consider the description of docker-compose.yml (Django + MySQL ③)
Django startup
Django notes
Django NullCharField
I tried to summarize the settings for various databases of Django (MySQL, PostgreSQL)
Build Python + django + nginx + MySQL environment using docekr
Build a Django environment on Raspberry Pi (MySQL)
Deploy Django apps on Ubuntu + Nginx + MySQL (Build)
Deployment method (2) (EC2 environment construction / Linux / MySQL settings)
(Case) Django (DRF) + uWSGI + Nginx + MySQL docker-compose.yml sample
Azure External Storage MySQL Challenges with Django (PTVS)
[Django3] Environment construction and various settings summary [Python3]
Create initial settings and staff apps in Django
[Django] About static file related settings (images, videos)
Do an ambiguous search for mysql in Django
DJango Memo: From the beginning (Error screen settings)
Django Getting Started Part 3 about Python3 & MySQL Connector
[Django] About static file related settings (css, js)