django - 配置 IIS 以服务 Django 应用程序
问题描述
我正在尝试Python 2.7.15
通过 IIS 发布一个 Django Web 应用程序(使用创建的)。首先我安装了应用程序:
:: setup folders
mkdir C:\Software\MyApp\
cd C:\Software\MyApp\
:: clone the git Repository
git clone https://gitlab.com/blablabla.git C:\Software\MyApp\MyAppServer
:: create the virtualenv
python -m pip install --upgrade pip
pip install virtualenv
virtualenv py2_env
call py2_env\Scripts\activate.bat
:: install the python-requirements in the virtualenv
pip install -r C:\Software\MyApp\MyAppServer\requirements.txt
:: copy all static files in C:\var\www
python C:\Software\MyApp\MyAppServer\manage.py collectstatic
:: just to check if the app works (and it works!)
python C:\Software\MyApp\MyAppServer\manage.py runserver
此时,我的文件夹组织是:
C:\
└── Software\
└── MyApp\
├── py2_env\
│ ├── Include\
│ ├── Lib\
│ ├── Scripts\
│ └── tcl\
└── MyAppServer\
├── manage.py
├── ...
└── myapp_django_server\
├── urls.py
├── wsgi.py
└── ...
我的py2_env
虚拟环境中安装的软件包是:
(py2_env) C:\Software\MyApp\py2_env\Scripts>pip freeze --local
Django==1.11.2
djangorestframework==3.6.3
numpy==1.12.1
pytz==2018.7
wfastcgi==3.0.0
此时,我按照本指南配置 IIS(我跳到了配置 IIS 以服务 Django 应用程序一章),但是最后,如果我浏览到http://localhost:81,我会收到此错误:
Error occurred:
Traceback (most recent call last):
File "C:\Software\EVARplanning\py2_env\Lib\site-packages\wfastcgi.py", line 847, in main
result = handler(record.params, response.start)
TypeError: get_wsgi_application() takes no arguments (2 given)
StdOut:
StdErr:
谁能告诉我怎么了?
解决方案
问题出在我WSGI_HANDLER
的 IIS 中FastCGI Settings
。我将它的值从django.core.wsgi.get_wsgi_application
to转换为django.core.wsgi.get_wsgi_application()
然后它可以工作。
推荐阅读
- javascript - Crypto-js 解密用加密加密的文件
- node.js - npm 错误!代码 ELIFECYCLE dyld:惰性符号绑定失败:未找到符号:_FSEventStreamCreate
- c++ - 无法更改索引 i 处的向量元素值
- stanford-nlp - Stanford.NLP.NER Nuget:这会将数据传递给服务还是在您的 devbox 上进行本地处理
- python - 删除逗号分隔符后将结果存储在字符串中的 Python 字符串操作
- .net-core - 不寻常的函数定义 - 这里发生了什么
- rust - Rust 进程使用 GitHub 操作失败,退出代码为 101
- javascript - 在反应中下载图像
- android - Android Hilt - 多模块项目转换错误
- excel - 根据当前时间运行宏