在每次修改models.py后,需要通过下列代码操作在本地记录更改操作同步数据库:
1、在终端输入:python manage.py makemigrations
qiang@09230:~/qiang/PyServer/bysms$ python3 /home/drc/qiang/PyServer/bysms/manage.py makemigrations
System check identified some issues:
Migrations for 'common':
common/migrations/0024_alter_lift_time.py
- Alter field time on lift
2、在终端输入;python manage.py migrate
qiang@09230:~/qiang/PyServer/bysms$ python3 /home/drc/qiang/PyServer/bysms/manage.py migrate
System check identified some issues:
Operations to perform:
Apply all migrations: admin, auth, common, common_case, contenttypes, sessions
Running migrations:
Applying common.0024_alter_lift_time... OK
3、最后重启下项目 python3 manage.py runserver 0.0.0.0:8888
# 以下命令是让项目在8888端口跑起来并且在后台不挂断运行(当然也可以写一个守护进程,防止项目掉线),并将项目打印日志写在django.log
qiang@09230:~/$ nohup python3 -u /home/drc/qiang/PyServer/bysms/manage.py runserver 0.0.0.0:8888 > django.log 2>&1 &
如果本文对您有所帮助请点赞收藏,支持一下谢谢。