简体   繁体   English

Django:python manage.py migrate 什么都不做

[英]Django: python manage.py migrate does nothing at all

I just started learning django, and as i try to apply my migrations the first problem occurs.我刚开始学习 django,当我尝试应用我的迁移时,第一个问题出现了。 I start the server up, type我启动服务器,输入

python manage.py migrate

and nothing happens.什么也没有发生。 No error, no crash, just no response.没有错误,没有崩溃,只是没有响应。

Performing system checks...

System check identified no issues (0 silenced).

You have 13 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.

May 01, 2017 - 11:36:27
Django version 1.11, using settings 'website.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
python manage.py migrate

And that's the end of my terminal feed.这就是我的终端提要的结尾。 I thought maybe it just looks like nothing happens, but no.我想也许它看起来好像什么也没发生,但没有。 The changes weren't applied and I can't proceed any further.更改未应用,我无法继续进行。 Any ideas on what's going on?关于发生了什么的任何想法?

Well, you say that you first start the server and then type in the commands.好吧,你说你首先启动服务器,然后输入命令。 That's also what the terminal feed you shared shows.这也是您共享的终端提要显示的内容。

Do not run the server if you want to run management commands using manage.py .如果要使用manage.py运行管理命令,请不要运行服务器。

Hit Ctrl + C to exit the server and then run your migration commands, it will work.按 Ctrl + C退出服务器,然后运行您的迁移命令,它将起作用。

Try:尝试:

python manage.py makemigrations
python manage.py migrate

@adam-karolczak n all @adam-karolczak n 所有

If there are multiple DJANGO Projects, it can happen that DJANGO_SETTINGS_MODULE is set to some other app in environment varibles, the current project manage.py will not point to current project settings thus the error.如果有多个 DJANGO 项目,可能会发生 DJANGO_SETTINGS_MODULE 在环境变量中设置为其他应用程序的情况,当前项目 manage.py 不会指向当前项目设置,从而导致错误。

So, confirm DJANGO_SETTINGS_MODULE in fact points to the settings.py of current project.所以,确认DJANGO_SETTINGS_MODULE实际上指向当前项目的settings.py。

Close the project if its running viz.如果项目正在运行,请关闭项目。 ctrl + C . Ctrl + C You can also check the server is not running ( linux ) by您还可以通过以下方式检查服务器未运行(linux)

ps -ef | grep runserver

Then kill the process ids if they exist.然后杀死进程ID(如果它们存在)。 If you confirmed settings.py in DJANGO_MODULE_SETTINGS is for the project you are having issue.如果您确认 DJANGO_MODULE_SETTINGS 中的 settings.py 是针对您遇到问题的项目。 Run the following it should resolve.运行以下它应该解决。

python manage.py makemigrations
python manage.py migrate

Hope it helps.希望能帮助到你。

I was getting the same error running this 2 command in terminal我在终端中运行这 2 个命令时遇到同样的错误

    python manage.py makemigrations
    python manage.py migrate

and then进而

    python manage.py runserver

solved my issues.解决了我的问题。 Thanks谢谢

你试过参数吗?

python manage.py makemigrations <app_name>

I had the same issue and the problem was that there was a pg_dump script running at the same time I was trying to migrate.我遇到了同样的问题,问题是在我尝试迁移的同时有一个 pg_dump 脚本正在运行。 After the dump was completed, migrations ran successfully.转储完成后,迁移成功运行。

  • Check that INSTALL_APPS app exists, if not add it检查 INSTALL_APPS 应用程序是否存在,如果不存在则添加它

  • Checks the model for default attributes检查模型的默认属性

  • Running this 2 command in terminal在终端中运行这 2 个命令

    python manage.py makemigrations python manage.py migration python manage.py makemigrations python manage.py migration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM