1. 新建app

startapp your_app_name

 

2. 删除app

migrate your_app_name zero

此外还需要删除整个App文件夹,并在settings.py的Installed Apps中移除该app。

 

3. makemigrations 和 migrate

官方解释如下:

migrate, which is responsible for applying and unapplying migrations.
makemigrations, which is responsible for creating new migrations based on the changes you have made to your models.

(原文链接:https://docs.djangoproject.com/en/2.2/topics/migrations/

大致的意思为:

  • makemigrations是将model层转为迁移文件migration
  • migrate将新版本的迁移文件执行,更新数据库。

这两中命令调用默认为全局,即对所有最新更改的model或迁移文件进行操作。如果想对部分app进行操作,就在其后追加app name

 

4. 创建超级用户

createsuperuser

执行完毕后按照提示输入用户名密码邮箱等信息即可。

 

相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2021-07-30
  • 2021-06-22
  • 2022-01-24
  • 2021-12-11
  • 2021-12-11
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2022-01-28
  • 2021-12-06
  • 2023-04-08
  • 2022-12-23
相关资源
相似解决方案