什么是我的Django应用程序的URL

时间:2014-06-13 15:40:10

标签: python django apache python-2.7

我已经在mod_wsgi虚拟机上使用ApacheUbuntu上传了我的第一个名为调查的Django应用程序(正在进行的工作),但我没有&# 39;不知道它的URL应该是什么。我的VM已通过http://phaedrus.scss.tcd.ie/bias_experiment的proxyPass公开。

在本地处理我的应用程序时,我只需转到http://127.0.0.1:8000/surveythree/根据我的urls.py(下方),我认为我只需要转到http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/即可在线查看我的调查应用程序。但是我似乎无法找到它......

我的问题:根据我的以下设置,我应该使用哪个网址来查找我的调查应用程序?或者我是否错过了此过程中的其他步骤?

项目已上传,我已重新启动服务器,我已将其设置为python manage.py runserver

我尝试过的一些网址

以下是我的设置以及到目前为止我尝试过的内容。

注意:我在Pydev中创建了一个Bias_Experiment Django项目。它有三个应用程序包含在src文件夹中。

  • 调查(我的工作项目)
  • 民意调查(我正在关注的教程)
  • bias_experiment(带有我的设置文件的根应用程序等)
来自bias_experiment / src / bias_experiment / urls.py的

我的网址格式

urlpatterns = patterns('',
    url(r'^polls/', include('polls.urls', namespace="polls")),
    url(r'^admin/', include(admin.site.urls)),        
    url(r'^surveythree/$', SurveyWizard.as_view([SurveyForm1, SurveyForm2, SurveyForm3, SurveyForm4, SurveyForm5])),   
)

我的虚拟主机位于/ etc / apache2 / sites-available / bias_experiment

<VirtualHost *:80>
ServerAdmin myemail@gmail.com
ServerName phaedrus.scss.tcd.ie/bias_experiment
ServerAlias phaedrus.scss.tcd.ie
WSGIScriptAlias /bias_experiment /var/www/bias_experiment/src/bias_experiment/index.wsgi

Alias /static/ /var/www/bias_experiment/src/bias_experiment/static/
<Location "/static/">
    Options -Indexes
</Location >
</VirtualHost >

我的WSGI文件位于/var/www/bias_experiment/src/bias_experiment/index.wsgi

import os
import sys
import site

# This is to add the src folder
sys.path.append('/var/www/bias_experiment/src/bias_experiment')

os.environ['DJANGO_SETTINGS_MODULE'] = 'bias_experiment.settings'

# Activate your virtual env
activate_env=os.path.expanduser("/var/www/bias_experiment/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

这是项目结构

enter image description here

我有一个previous question related to this,其中有多个问题向我指出,我已经修好了所以我在这里重新发布了这个问题。我一直关注几个教程作为该问题的详细信息。

对此的任何帮助都将受到广泛赞赏。

感谢Deepend

编辑:我的Apache错误日志:tail /var/log/apache2/error.log

(bias_experiment)spillab@kdeg-vm-18:/var/www/bias_experiment/src$ sudo su
root@kdeg-vm-18:/var/www/bias_experiment/src# tail /var/log/apache2/error.log
[Fri Jun 13 16:21:04 2014] [error] [client 134.226.38.233] File does not exist: /var/www/bias_experiment/surveythree, referer: https://stackoverflow.com/questions/24209181/what-should-be-the-url-of-my-django-application/24209864?noredirect=1
[Fri Jun 13 16:22:36 2014] [error] [client 134.226.38.233] PHP Notice:  Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in /var/www/bias_experiment/brendy.php on line 24, referer: http://phaedrus.scss.tcd.ie/bias_experiment/
[Fri Jun 13 16:22:36 2014] [error] [client 134.226.38.233] PHP Notice:  Undefined index: brendy in /var/www/bias_experiment/brendy.php on line 27, referer: http://phaedrus.scss.tcd.ie/bias_experiment/
[Fri Jun 13 16:22:36 2014] [error] [client 134.226.38.233] PHP Notice:  Use of undefined constant action - assumed 'action' in /var/www/bias_experiment/brendy.php on line 72, referer: http://phaedrus.scss.tcd.ie/bias_experiment/
[Fri Jun 13 16:22:36 2014] [error] [client 134.226.38.233] PHP Notice:  Undefined index: action in /var/www/bias_experiment/brendy.php on line 72, referer: http://phaedrus.scss.tcd.ie/bias_experiment/
[Fri Jun 13 16:22:36 2014] [error] [client 134.226.38.233] PHP Warning:  include(footer.php): failed to open stream: No such file or directory in /var/www/bias_experiment/brendy.php on line 118, referer: http://phaedrus.scss.tcd.ie/bias_experiment/
[Fri Jun 13 16:22:36 2014] [error] [client 134.226.38.233] PHP Warning:  include(): Failed opening 'footer.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/bias_experiment/brendy.php on line 118, referer: http://phaedrus.scss.tcd.ie/bias_experiment/
[Fri Jun 13 16:22:37 2014] [error] [client 134.226.38.233] File does not exist: /var/www/bias_experiment/special.css, referer: http://phaedrus.scss.tcd.ie/bias_experiment/brendy.php
[Fri Jun 13 16:22:37 2014] [error] [client 134.226.38.233] File does not exist: /var/www/bias_experiment/images, referer: http://phaedrus.scss.tcd.ie/bias_experiment/brendy.php
[Fri Jun 13 16:22:37 2014] [error] [client 134.226.38.233] File does not exist: /var/www/bias_experiment/images, referer: http://phaedrus.scss.tcd.ie/bias_experiment/brendy.php
root@kdeg-vm-18:/var/www/bias_experiment/src# 

3 个答案:

答案 0 :(得分:1)

网址应为http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/

我认为Apache配置中有一个小错误,这可能是我的错(抱歉):你需要一个尾部斜杠,所以:

WSGIScriptAlias /bias_experiment/ /var/www/bias_experiment/src/bias_experiment/index.wsgi

另请注意,您不需要运行manage.py runserver,这在Apache为您的应用程序提供服务时毫无意义。

答案 1 :(得分:0)

这是在你的/ static /文件夹中吗?

http://phaedrus.scss.tcd.ie/bias_experiment/static/

答案 2 :(得分:-1)

尝试进行此更改:

Apache conf:

WSGIApplicationGroup %{GLOBAL}
ServerName phaedrus.scss.tcd.ie
WSGIScriptAlias /bias_experiment/ /var/www/bias_experiment/src/bias_experiment/index.wsgi
WSGIDaemonProcess bias_experiment processes=4 threads=25 display-name=%{GROUP}
WSGIProcessGroup bias_experiment
WSGIPassAuthorization On

您需要重新启动Apache服务器。