25
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Django + MySQLでの設定あれこれ

Last updated at Posted at 2016-06-25

追記 2019/10/29

未だにこの記事読まれてるの謎なんですけど以前に以下のブログ記事を書いたのでこっちを読んでほしい

DjangoでPyMySQLを使うのそろそろやめよう

セットアップ

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

settings.pyにMySQL接続設定

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

manage.pyにMySQLを使うように設定

manage.py
import pymysql
pymysql.install_as_MySQLdb()

最終セットアップ

$ python manage.py makemigrations
$ python manage.py migrate
$ python manage.py createsuperuser
$ python manage.py runserver
25
33
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?