DB設定と言語、タイムゾーン
めんどくさいのでmysite/settings.py
のgit diffを貼り付けておく。
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+# 'ENGINE': 'django.db.backends.sqlite3',
+# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME': '******',
+ 'USER': '******',
+ 'PASSWORD': '******',
+ 'HOST': 'localhost',
+ 'PORT': '3306',
}
}
@@ -103,9 +109,11 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
-LANGUAGE_CODE = 'en-us'
+#LANGUAGE_CODE = 'en-us'
+LANGUAGE_CODE = 'ja'
-TIME_ZONE = 'UTC'
+#TIME_ZONE = 'UTC'
+TIME_ZONE = 'Asia/Tokyo'
DBマイグレーション
DBの初期化をして、管理用アカウントの登録先とそれに付随する諸々のテーブルを定義。
$ python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name.../usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py:101: Warning: (1146, "Table 'mysql.column_stats' doesn't exist")
return self.cursor.execute(query, args)
OK
Applying auth.0002_alter_permission_name_max_length.../usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py:101: Warning: (1146, "Table 'mysql.column_stats' doesn't exist")
return self.cursor.execute(query, args)
OK
Applying auth.0003_alter_user_email_max_length.../usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py:101: Warning: (1146, "Table 'mysql.column_stats' doesn't exist")
return self.cursor.execute(query, args)
OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length.../usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py:101: Warning: (1146, "Table 'mysql.column_stats' doesn't exist")
return self.cursor.execute(query, args)
/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py:101: Warning: (1146, "Table 'mysql.index_stats' doesn't exist")
return self.cursor.execute(query, args)
OK
Applying sessions.0001_initial... OK
管理用アカウント作成
古いバージョンのDjangoはDB初期化時に、ユーザ作成も聞いてくれるらしいが、聞いてもらえなかったので自分で作った。
$ python3 manage.py createsuperuser
Username (leave blank to use 'kumanoshuta'): shoota
Email address:
Password:
Password (again):
This password is too short. It must contain at least 8 characters.
Password:
Password (again):
Error: Your passwords didn't match.
Password:
Password (again):
Superuser created successfully.
途中でパスワード短くて怒られた。
次はアプリの生成をする