python - Errno 5 request.GET 输入/输出错误
问题描述
一旦我的 Django 站点被部署到“生产”并使用 Gunicorn 和 nginx 设置为实时,一些之前确实有效的 URL 现在会导致 [Errno 5] 输入/输出错误。我已经通过设置 DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False' 在 settings.py 中禁用了 DEBUG flat
解决此问题的最佳方法是什么?我忽略了部署的任何明显部分吗?
我的 nginx conf.d 文件如下所示:
server {
listen 80 default_server;
server_name rafalkukawski.tech;
root /var/www/;
location / {
proxy_pass http://localhost:8000;
}
location /img/ {
}
location /static/ {
autoindex on;
}
}
受此影响的观点有:
# called like: http://rafalkukawski.tech/todo/new?todo_name=new&due_date=2021-03-25&importance=0&required_time=1
def new_item(request):
todo_name = request.GET.get('todo_name', '')
#todo_auth = request.GET.get('todo_auth', '')
due_date = request.GET.get('due_date', '')
importance = request.GET.get('importance', '0')
required_time = request.GET.get('required_time', '1') #this in particular is highlightet as the faulty line of code
item = todo_item(todo_name = todo_name, todo_auth = request.user.username, due_date = due_date, importance = importance, required_time = required_time)
item.save()
return HttpResponse(item.due_date)
或者
#called like: http://rafalkukawski.tech/ap/painting/1
#not sure what line exactly is causing this since the error only displays "<source code not available>"
def template_painting(request, painting_id):
painting = Painting.objects.get(pk=painting_id)
images = Imgs.objects.filter(painting=painting_id)
lang_code = request.LANGUAGE_CODE
template =loader.select_template(['ap/'+lang_code+'/painting.html','ap/en/painting.html'])
#template = loader.get_template('ap/'+lang_code+'/painting.html')
context = {"painting":painting, "images":images}
return HttpResponse(template.render(context, request))
解决方案
推荐阅读
- xamarin - 新的 Xamarin.Forms 项目缺少引用
- android - 活动名称混淆的解决方法
- javascript - 使用 YQL 将数据 POST 到 URL
- python - Keras 错误“您必须为占位符张量提供一个值”
- c# - 使用 file.move 在 C# 中重命名新文件
- xero-api - UnauthorizedException token_rejected
- r - R data.table 按组计算多列中的唯一值
- ios - 领域,对象已被删除或失效
- javascript - 我怎样才能使一个框适合css中的图片(观看视频以了解我的意思)
- python - 搅拌机脚本 - 不正确的纹理添加