python manage.py runserver 不显示任何内容

python manage.py runserver doesn't display anything

我以前用 django 工作,过去我没有遇到过这个问题,然后我转移了一段时间 Laravel(当然我在 windows 我不记得了)。

现在当我点击 python manage.py runserver 时.. 没有任何反应并且 shell 似乎被绞死了。一旦我按下 crt + C 悬停。正常 window 突然出现说:

You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. January 08, 2019 - 14:16:30 Django version 2.1.1, using settings 'django_project.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK.

不过我可以去 http://127.0.0.1:8000/ and I have the welcome page of django with this line added enter image description here

我知道这听起来很疯狂,请原谅,因为我是新手,请提前感谢

看来您必须应用迁移。

你只是运行他说的:

python manage.py migrate

我认为在继续之前最好先查看文档:您必须了解模型在 Django 中的工作方式。 看看to the documentation first。 我的建议是遵循 "first app" 教程。去here

应用迁移运行:

python manage.py makemigrations
python manage.py migrate

好像您刚刚安装了 django,每次安装时,您都应该应用迁移。这会将数据库状态与您当前的模型和迁移集同步。

More about migrations

manage.py 中的第一行在 windows 中断文件。第一行应如下所示:

#!/usr/bin/env python

删除 它将解决问题