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后可以在不影响现有数据的前提下重建表结构。
示例:
[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
即可搞定。
2024年云服务器租用优惠价格,11月最新: