在Django开发服务器上工作,但不在apache上工作 [英] working on django development server but not on apache

查看:43
本文介绍了在Django开发服务器上工作,但不在apache上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在apache服务器上遇到问题,我们已经编写了代码,如果在form字段中输入的url有效,它将显示一条错误消息,当我通过django开发服务器运行代码时,它可以正常工作,显示错误消息,但是在通过apache运行时,则不显示错误消息,只是返回到该页面本身.这是python和html的以下代码:

i am facing an issue with the apache server, we have written the code, in which if the url entered in the form field is valid it will display an error message, when i run the code through django developement server it works fine, displays the error message, but when running through apache, then does not show the error message just returns back to that page itself. here is the code below of both the python and the html:

objc= {
    "addRecipeBttn": "/project/add",
    "addRecipeUrlBttn": "/project/add/import",
    }

def __showAddRecipe__(request):
    global objc
    #global objc
    if "userid" in request.session:
        objc["ErrorMsgURL"]= ""
        try:
            urlList= request.POST
            URL= str(urlList['url'])
            URL= URL.strip('http://')
            URL= "http://" + URL

            recipe= __addRecipeUrl__(URL)

            if (recipe == 'FailToOpenURL') or (recipe == 'Invalid-website-URL'):
                #request.session["ErrorMsgURL"]= "Kindly check URL, Please enter a valid URL"
                objc["ErrorMsgURL"]= "Kindly check URL, Please enter a valid URL"
                print "here global_context =", objc
                return HttpResponseRedirect("/project/add/import/")
                #return render_to_response('addRecipeUrl.html', objc, context_instance = RequestContext(request))
            else:
                objc["recipe"] = recipe
                return render_to_response('addRecipe.html',
                    objc,
                    context_instance = RequestContext(request))
        except:
            objc["recipe"] = ""
            return render_to_response('addRecipe.html',
                objc,
                context_instance = RequestContext(request))
    else:
        login_redirect['next']= "/project/add/"
        return HttpResponseRedirect("/project/login")



def __showAddRecipeUrl__(request):
    global objc
    if "userid" in request.session:
        return render_to_response('addRecipeUrl.html',
            objc, 
            context_instance = RequestContext(request))
    else:
        login_redirect['next']= "/project/add/import/"
        return HttpResponseRedirect("/project/login")
_

HTML文件:-

请检查一下,并让我知道是否有人可以在django开发服务器上解决此问题.

kindly check and let me know if anyone can help on this issue, its working on django development server.

谢谢Suhail

推荐答案

谢谢大家的支持,问题已经解决,我是这样做的.

hey guys, thanks for the support, the issue is resolved, i did it this way.

def showAddRecipe(request):
    #global objc
    if "userid" in request.session:
        objc["ErrorMsgURL"]= ""
        try:
            urlList= request.POST
            URL= str(urlList['url'])
            URL= URL.strip('http://')
            URL= "http://" + URL

            recipe= __addRecipeUrl__(URL)

            if (recipe == 'FailToOpenURL') or (recipe == 'Invalid-website-URL'):
                #request.session["ErrorMsgURL"]= "Kindly check URL, Please enter a valid URL"
                objc["ErrorMsgURL"]= "Kindly check URL, Please enter a valid URL"
                print "here global_context =", objc
                arurl= HttpResponseRedirect("/project/add/import/")
                arurl['ErrorMsgURL']= objc["ErrorMsgURL"]
                return (arurl)
            else:
                objc["recipe"] = recipe
                return render_to_response('addRecipe.html',
                    objc,
                    context_instance = RequestContext(request))
        except:
            objc["recipe"] = ""
            return render_to_response('addRecipe.html',
                objc,
                context_instance = RequestContext(request))
    else:
        login_redirect['next']= "/project/add/"
        return HttpResponseRedirect("/project/login")

这篇关于在Django开发服务器上工作,但不在apache上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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