首次上传Python应用程序。 URLconfig URLS不起作用 [英] Uploading Python application for the first time. URLconfig URLS not working

查看:106
本文介绍了首次上传Python应用程序。 URLconfig URLS不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试在网上获取一个Django应用程序,但是我遇到了URls的问题。



我的应用程序的工作本地URL是




  • http:// localhost:8000 / surveythree / - 这样可以预期。



但是,当我将项目上传到我的主机帐户时,我似乎无法使用URLconf中提供的缩短的URL查找相关页面在这种情况下,应该是/ surveythree /

  url(r'^ surveythree / $',SurveyWizard.as_view([SurveyForm1 ,SurveyForm2,SurveyForm3,SurveyForm4,SurveyForm5])),

如果我使用但是完整的文件路径。



http://www.mywebsite.com/bias_experiment/src/survey/templates/formtools/wizard/wizard_form.html



我以为这个好处的URLconf是将URL缩短为以下之一:



有没有什么简单的,我在这里错过?如果有人可以告诉我缩短的URL应该是基于以上的,那将是巨大的。我一直在尝试多个组合一段时间,但我不知道我是在圈子里还是做错了。



提前感谢。

解决方案

看起来你实际上没有使用正确的服务器部署您的站点。您不能将文件上传到任何网络服务器,然后运行:您需要配置一个wsgi服务器并将其连接到您的应用程序。



文档是<一个href =https://docs.djangoproject.com/en/1.6/howto/deployment/ =nofollow>这里,但老实说,如果你的大学服务器支持它,我会感到惊讶所有,如果你有一个共享文件夹。您可以使用FastCGI来实现,但我不会抱有很多希望。



(甚至虽然你说那个长的URL工作,我保证你所看到的只是原始的HTML模板,没有任何实际的动态功能将会像这样工作,如你所见实际上试图提交该网址的表单。)


It is my first time trying to get a Django application live on the net but I am having an issue with the URls.

The working local URL of my application is

  • http://localhost:8000/surveythree/ - This works as expected.

However when I upload my project to my hosting account I cant seem to locate the relevant page using the shortened URL as provided by the URLconf, in this case it should be /surveythree/

url(r'^surveythree/$', SurveyWizard.as_view([SurveyForm1, SurveyForm2, SurveyForm3, SurveyForm4, SurveyForm5])),   

I can locate the page if I use the full filepath however.

http://www.mywebsite.com/bias_experiment/src/survey/templates/formtools/wizard/wizard_form.html

I thought the benefit of the URLconf was to shorten the URL to something like one of the following

Is there something simple that I am missing here? If anyone could tell me what the shortened URL should be based on the above it would be great. I have been trying multiple combinations for a while now but I don't know if I am going around in circles or doing it wrong.

Thanks in advance.

解决方案

It doesn't look like you have actually deployed your site with a proper server. You can't just upload the files to any webserver and expect then to run: you need to configure a wsgi server and connect it to your app.

The documentation is here but to be honest I'd be amazed if your college server supported it at all, if all you have is a shared folder. You may be able to get it to work with FastCGI, but I wouldn't hold out a whole lot of hope.

(And even though you say that going to that long URL "works", I'd guarantee that all you're seeing is the raw HTML template. There's no way that any actual dynamic functionality will be working like that, as you'd see if you actually tried to submit the form at that URL.)

这篇关于首次上传Python应用程序。 URLconfig URLS不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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