时间:2021-07-01 10:21:17 帮助过:2人阅读
DATABASES = { ‘default‘: { ‘ENGINE‘: ‘django.db.backends.mysql‘, ‘NAME‘: ‘blogdb‘, ‘USER‘: ‘root‘, ‘PASSWORD‘: ‘664390‘, ‘HOST‘: ‘‘, ‘POST‘: ‘‘, } } #自定义model AUTH_USER_MODEL = ‘blog.User‘
C:\Users\66439>mysql -uroot -p664390 ——进入mysql数据库 mysql> CREATE DATABASE blogdb; ——创建一个 ‘blogdb‘ 表 Query OK, 1 row affected (0.00 sec)
D:\python\blog_project>d:\python\blog_project_venv\Scripts\activate
(blog_project_venv) D:\python\blog_project>manage.py makemigrations 2016-05-25 23:16:29,582 [MainThread:9804] [django.db.backends:89] [utils:execute] [DEBUG]- (0.000) SET SQL_AUTO_IS_NULL = 0; args=None Migrations for ‘blog‘: 0001_initial.py: - Create model Ad - Create model Article - Create model Catagory - Create model Category - Create model Comment - Create model Links - Create model Tag - Create model User - Add field user to comment - Add field category to article - Add field tag to article
makemigrations blog ——带上 ‘blog‘ ,只生成 ‘blog‘ 内的 ‘models.py‘
- Add field user to article
(blog_project_venv) D:\python\blog_project>manage.py migrate
万里长征第二步——django个人博客(第四步 ——创建数据库)
标签: