Initialize your Django app

DB settings and language, time zone

It's annoying, so paste the git diff from mysite / settings.py.

 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 migration

Initialize the DB and define the registration destination of the management account and various tables attached to it.

$ 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

Create an administrative account

It seems that the old version of Django will ask you to create a user when you initialize the DB, but I didn't hear it, so I made it myself.

$ 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.

I was angry because my password was short on the way.

Next, do Generate App

Recommended Posts

Initialize your Django app
Create your first app with Django startproject
Launch my Django app
Publish your Django app on Amazon Linux + Apache + mod_wsgi
Tuning your Django admin site
Create your own Django middleware
Install Django on your Mac
A quick look at your profile within the django app
Register your Django application in your project
Deploy your Django application on Heroku
Django
Implement a Django app on Hy
[Django] Create your own 403, 404, 500 error pages
Build your Django app on Docker and deploy it to AWS Fargate
Your own Twitter client made with Django
Create a model for your Django schedule
[Django] Want to customize your admin page?
Deploy the Django app on Heroku [Part 2]
Deploy the Django app on Heroku [Part 1]
Django: Implement reusable APP settings following Django RestFrameWork
Django Tutorial (Blog App Creation) ⑤ --Article Creation Function
Django Tutorial (Blog App Creation) ④ --Unit Test
[Python] Introduce UIKit3 to your Django project