django视图-502错误的网关 [英] django views - 502 bad gateway

查看:237
本文介绍了django视图-502错误的网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生产服务器中测试我的项目,在那里我的Web应用程序中出现了各种功能的错误,这些错误在我的计算机上可以正常运行.

I'm testing my project in the production server where I'm getting several errors of various features in my web application which is working perfectly on my computer.

请转到 http://qlimp.com 并使用以下用户名/密码登录:nirmal/karurkarur 然后转到 http://qlimp.com/cover ,您将找到一个调色板.上传图片,并执行与 flavors.me 类似的操作.我在这里遇到几个问题(图像,文本,其他信息未存储在数据库中).

Please go to http://qlimp.com and login using this username/password: nirmal/karurkarur Then go to http://qlimp.com/cover You'll find a palette where you can upload images and do something similar to flavors.me. I'm having several problems here(images,text,other information are not getting stored in the database).

我认为设置没有问题.问题是它甚至无法正确进入Django视图,但在我的计算机上没有任何问题.有没有人遇到过同样的问题?我想知道为什么它不起作用.

I think there is no problem with the setup. The problem is it is not even entering into the Django views properly but working without any problem on my computer. Is there anyone experienced the same problem? I'm wondering why is it not working.

您还可以在 http://qlimp.com/signup/中检出,您可以找到数据无法存储的问题.

Also you can check out in http://qlimp.com/signup/ and you can find the problem where the datas are not get stored.

所以有很多问题我不能在一个问题中提出(不是stackoverflow文化),所以我问这个问题.

So there are many problems which I can't ask in one question(not a stackoverflow culture) and so I'm asking this.

当我上传图片时,我在 chrome检查器的网络标签"中签入,它显示 502错误的网关

When I upload the image I checked in chrome inspector 'network tab' it shows 502 bad gateway

这是我的Django views.py : https://gist.github.com/2778242

Here is my Django views.py: https://gist.github.com/2778242

jQuery ajax图片上传的代码:

$('#id_tmpbg').live('change', function()
    {
    $("#ajax-loader").show();
    $("#uploadform").ajaxForm({success: showResponse}).submit();
    });

    function showResponse(responseText, statusText, xhr, $form)  { 
    $.backstretch(responseText)
    $("#ajax-loader").hide();
    }

在我看来,我还检查了它实际上是进入了request.is_ajax()而不是进入了form.is_valid().为什么会这样呢?我正在上传正确的格式.

And I also checked that it is actually entering into the request.is_ajax() but not into form.is_valid() in my views. Why is it so? I'm uploading the right format.

有人可以识别我犯的错误吗?我还需要一个答案,为什么代码不能在生产服务器上正常工作,而生产服务器实际上在开发服务器上工作(这对解决其余问题将很有帮助).

Could anyone identify the mistake I've done? Also I need an answer on Why the code is not working on production server which is actually working on the development server (this would be helpful for me to solve rest of the problems).

开发服务器:Ubuntu 11.10/Python 2.7/Django 1.3.1

Development server: Ubuntu 11.10/Python 2.7/Django 1.3.1

生产服务器:Ubuntu 12.04/Python 2.7/Django 1.3.1

Production server: Ubuntu 12.04/Python 2.7/Django 1.3.1

更新

每个使用相同用户名/密码登录的人都存在一些问题.因此,请在那里注册并显示 [Errno 111]连接被拒绝,没关系,您可以登录.

There is some problem in everyone signing in with the same user/password. So please register there and it shows [Errno 111] Connection refused, doesn't matter, you can login then.

UPDATE-2

实际上问题出在form.is_valid()上,所以我将其删除并进行了检查,但现在却出现此错误:

Actually the problem is with form.is_valid() so I removed it and checked but now I'm getting this error:

Exception Type: ValueError
Exception Value:    The BackgroundModel could not be created because the data didn't validate.
Exception Location: /home/nirmal/project/local/lib/python2.7/site-packages/django/forms/models.py in save_instance, line 73

我一直在上传正确的图片格式,但我不知道为什么它没有通过验证.

I'm all-time uploading the right Image format and I don't know why it is not validating.

UPDATE-3

对于 http://qlimp中的所有静态文件,我得到 304未修改. com/cover 这将是无法正常工作的问题吗?

I'm getting 304 Not Modified for all the static files in http://qlimp.com/cover Will this be a problem for not working?

推荐答案

我发现过去三天困扰我的问题.这是因为我忘记了在PIL安装之前执行此sudo apt-get install libjpeg62 libjpeg62-dev zlib1g-dev的原因,这就是为什么该映像未得到验证的原因.

I've found the problem which was stucking me for the past 3 days. It is because I've forget to do this sudo apt-get install libjpeg62 libjpeg62-dev zlib1g-dev before the PIL installation, that is why the image is not get validated.

下一个问题是,我在settings.py文件中提供了MEDIA_ROOT的相对路径,该路径导致404 NOT FOUND,我将其更改为绝对路径.

The next issue is I've given a relative path for the MEDIA_ROOT in my settings.py file which leads to 404 NOT FOUND and I changed it to absolute path.

因此,这些都是简单的错误,会导致一些神秘的错误.也感谢大家的帮助.

So these are simple mistakes which leads to some mysterious errors. Also Thanks to everyone for the help.

这篇关于django视图-502错误的网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆