Django执行命令python manage.py runserver
,提示“You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.”的解决方法,码笔记分享:
python manage.py runserver错误及解决方法
执行命令:python manage.py runserver
报错:“You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.”
解决方法
报错信息已经说的很清楚了,让我们“Run 'python manage.py migrate' to apply them.”,运行python manage.py migrate
命令即可。那么这个命令中的migrate是什么?它能够让我们在修改Model后可以在不影响现有数据的前提下重建表结构。
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
[root@mabiji HelloDjango]# python manage.py runserver 0.0.0.0:80 Performing system checks... System check identified no issues (0 silenced). You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them. January 21, 2019 - 13:57:40 Django version 1.8.9, using settings 'HelloDjango.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C. ^Z [1]+ 已停止 python manage.py runserver 0.0.0.0:8000 [root@mabiji HelloDjango]# python manage.py migrate Operations to perform: Synchronize unmigrated apps: staticfiles, messages Apply all migrations: admin, contenttypes, auth, sessions Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... 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 sessions.0001_initial... OK |
执行命令python manage.py migrate
后,你会发现,在你的Django目录下面多了一个dg.sqlite3文件。
然后再重新执行命令python manage.py runserver
即可搞定。
2023腾讯云服务器超便宜,这个价格太可以了,抓紧上车!
- 2核2G3M服务器30元/3个月:点此直达
- 2核2G3M服务器95元一年:点此直达
- 2核2G4M服务器112元/1年:点此直达
- 2核2G4M服务器396元/1年:点此直达
- 2核4G5M服务器168元/3年:点此直达
- 2核4G5M服务器628元/3年:点此直达
- 4核8G12M服务器446元/1年 518元15个月:点此直达
- 8核16G18M服务器1668元/15个月
- 16核32G28M服务器3468元/15个月
注意:以上特价轻量服务器限制条件为“产品首单特惠”,如果你的腾讯云账号已经是老用户,建议重新注册一个腾讯云账号,如果你是新用户符合条件,那么无脑入,这个CPU内存带宽配置,价格确实便宜,值得买!
2023云服务器降价了!阿里云VS腾讯云
阿里云:2023阿里云服务器价格便宜到家了(值得买)
腾讯云:2023腾讯云2核4G服务器8M带宽70元一年(多配置可选)
华为云:2023华为云优惠活动云服务器60元一年起(查看更多配置报价)
发表评论