Django和Python + uWSGI

San*_*4ez 7 python django wsgi nginx uwsgi

使用指令我尝试连接Python + uWSGI.

我在一个文件夹/ home/sanya/django/pasteurl中创建了默认项目.但是,在我得到的浏览器中打开它

uWSGI Error
wsgi application not found
Run Code Online (Sandbox Code Playgroud)

日志包含以下内容:

binding on TCP port: 9001
your server socket listen backlog is limited to 64 connections
added /home/sanya/django/pasteurl to pythonpath.
initializing hooks...done.
...getting the applications list from the 'django' module...
uwsgi.applications dictionary is not defined, trying with the "applications" one...
applications dictionary is not defined, trying with the "application" callable.
static applications not defined, you have to use the dynamic one...
spawned uWSGI master process (pid: 7637)
spawned uWSGI worker 1 (pid: 7646)
spawned uWSGI worker 2 (pid: 7647)
spawned uWSGI worker 3 (pid: 7648)
spawned uWSGI worker 4 (pid: 7649)
Run Code Online (Sandbox Code Playgroud)

文件/home/sanya/django/pasteurl/django.wsgi

import os
import django.core.handlers.wsgi

# init django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'pasteurl.settings'

# define wsgi app
application = django.core.handlers.wsgi.WSGIHandler()

# mount this application at the webroot
# applications = { '/': 'application' }
Run Code Online (Sandbox Code Playgroud)

正如我意识到的那样,这个应用程序字典出了问题

aar*_*ing 1

FWIW,查看源代码,从第 1997 行开始,我们看到 uWSGI 在找不到字典时会发出您收到的错误消息的确切序列applications

查看您的django.wsgi文件,我们看到该行,

`applications = {'/': 'application'} 
Run Code Online (Sandbox Code Playgroud)

被注释掉了。我想知道我们能对此做些什么;)

顺便说一句,我使用google找到了源代码。在谷歌上搜索引号中的错误消息通常是一件好事。当我点击该链接并意识到我很幸运能够直接从 google 找到源代码(这种情况越来越多)时,我按 Ctrl-F 进行“在页面上查找”,然后在浏览器中重新输入错误消息页面搜索功能直接引导我到相关行。