working on django development server but not on ap

2019-08-09 02:51发布

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")
_

The HTML file:-

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

Thank you Suhail

1条回答
聊天终结者
2楼-- · 2019-08-09 03:23

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")
查看更多
登录 后发表回答