【问题标题】:You have 3 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth您有 3 个未应用的迁移。在您为应用程序应用迁移之前,您的项目可能无法正常工作:admin、auth
【发布时间】:2017-01-21 00:26:34
【问题描述】:

我刚刚创建了 Django 项目并运行了服务器。 它工作正常,但向我显示警告,如

You have 14 unapplied migration(s)...

然后我跑了

python manage.py migrate

在终端中。它有效,但向我展示了这一点

?: (1_7.W001) MIDDLEWARE_CLASSES is not set.
    HINT: Django 1.7 changed the global defaults for the MIDDLEWARE_CLASSES.
django.contrib.sessions.middleware.SessionMiddleware, django.contrib.auth.middleware.AuthenticationMiddleware, and django.contrib.messages.middleware.MessageMiddleware were removed from the defaults. If your project needs these middleware then you should configure this setting.

现在我在启动服务器后收到此警告。

You have 3 unapplied migration(s). 
Your project may not work properly until you apply
the migrations for app(s): admin, auth.

那么如何正确迁移以消除此警告?

我正在使用 PyCharm 并尝试通过 PyCharm 和终端创建项目并遇到同样的问题。

~$ python3.5 --version
Python 3.5.2

>>> django.VERSION
(1, 10, 1, 'final', 1)

【问题讨论】:

  • 你试过 python manage.py makemigrations python manage.py migrate
  • @Dimitris 是的。 python manage.py makemigrations 显示相同的警告“MIDDLEWARE_CLASSES is not set...”没有任何变化。
  • 而且你真的设置了 MIDDLEWARE_CLASSES?
  • 在你的 settings.py 文件中你有这个设置吗? docs.djangoproject.com/el/1.10/topics/http/middleware MIDDLEWARE = ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django .contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ]
  • 您尝试使用 django 版本 1.10 运行 django 项目 1.7 版,您发布的错误说要从 settings.py 中的中间件中删除这些中间件设置

标签: python django python-3.x pycharm


【解决方案1】:

所以我的问题是我使用了错误的 python 版本进行迁移。

python3.5 manage.py migrate

解决问题。

【讨论】:

    【解决方案2】:

    您可能使用了错误的 django 版本。你需要django1.10

    【讨论】:

      猜你喜欢
      • 2019-07-10
      • 2020-03-08
      • 1970-01-01
      • 2012-04-29
      • 2020-08-23
      • 1970-01-01
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多