【发布时间】: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