python – 自定义设置和django 1.10中的wsgi给我错误

我有运行服务器的自定义设置的这个错误:

 salahaddin@TulipanROG  ~/Proyectos/tiempoturco/tiempoturco  (tiempoturco)  ./manage.py runserver                                                                                                                                            ✓  640  23:22:06 
Performing system checks...

System check identified no issues (0 silenced).
June 19, 2016 - 23:22:07
Django version 1.10a1, using settings 'tiempoturco.settings.dev'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f288d67f2f0>
Traceback (most recent call last):
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 142, in inner_run
    handler = self.get_handler(*args, **options)
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
    handler = super(Command, self).get_handler(*args, **options)
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
    return get_internal_wsgi_application()
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
    return import_string(app_path)
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
    module = import_module(module_path)
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/salahaddin/Proyectos/tiempoturco/tiempoturco/tiempoturco/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
    return WSGIHandler()
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
    self.load_middleware()
  File "/home/salahaddin/Proyectos/tiempoturco/lib/python3.5/site-packages/django/core/handlers/base.py", line 79, in load_middleware
    mw_instance = middleware(handler)
TypeError: object() takes no parameters

我有这个文件夹结构:
enter image description here

在这里我的wsgi代码:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tiempoturco.settings.dev")

application = get_wsgi_application()

我的manage.py代码:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tiempoturco.settings.dev")
    try:
        from django.core.management import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
        try:
            import django
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"
            )
        raise
    execute_from_command_line(sys.argv)

怎么了?
我可以执行迁移并创建超级用户,使用shell plus和其他命令,但我可以运行服务器.我尝试将设置值更改为production和dev,将此值放在__init__.py中并执行其他更少但没有任何内容.

和middleware_clases:

MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

我无法找到有关此信息,我正在测试django 1.10.

我对django 1.9.7没有问题,我不知道为什么.同样地,当我创建一个带有wigtail 1.6i的项目在runserver中没有问题时,wagtail 1.6安装了django 1.9.7yet,但是我替换它然后用于django 1.10然后尝试在运行迁移后运行项目并创建一个超级用户,当我在浏览器中回家时,我可以看到该页面,也可以看到管理员.

所以,我没有使用其他应用程序的问题,但创建手动多个设置我自己给我这个错误.

谁能帮我?

最佳答案
尝试更改MIDDLEWARE_CLASSES

MIDDLEWARE_CLASSES = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
]

转载注明原文:python – 自定义设置和django 1.10中的wsgi给我错误 - 代码日志