什么应该是我的Django应用程序的URL [英] What should be the URL of my Django Application

查看:139
本文介绍了什么应该是我的Django应用程序的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 mod_wsgi Apache

/ code>在 Ubuntu 虚拟机,但我不知道它的URL应该是什么。我的虚拟机已通过proxyPass公开发布,网址为



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

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

另请注意,您不需要运行manage.py runserver,这是毫无意义的因为Apache正在为您的应用服务。


I have uploaded my first Django Application called survey (Its a work in progress) using mod_wsgi with Apache on an Ubuntu VM but I don't know what the URL of it should be. My VM has been made public through a proxyPass at http://phaedrus.scss.tcd.ie/bias_experiment.

When working on my application locally I simply go to http://127.0.0.1:8000/surveythree/ Based on my urls.py (below) I thought that I would simply have to go to http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ to see my Survey application online. However I cant seem to find it...

My question: What URL should I be using to locate my Survey Application based on my below settings? Or have I missed some other step in the process?

The project has been uploaded, I have restarted the server, I have set it running with python manage.py runserver

Some of the urls I have tried

Below is my setup and what I have tried so far.

NOTE: I have a Bias_Experiment Django Project created in Pydev. It has three applications contained within an src folder.

  • survey (my working project)
  • polls (a tutorial i was following)
  • bias_experiment (the root application with my settings file etc)

My URL patterns from 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])),   
)

My virtual host located at /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 >

My WSGI file located at /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()

This is the project structure

I had a previous question related to this which had multiple issues pointed out to me which I have since fixed so I am re-posting this here. I have been following several tutorials as details in that question.

Any help with this would be massively appreciated.

Thanks Deepend

EDIT: My Apache Error Log: 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# 

解决方案

The URL should be http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/

I think there is one tiny error in the Apache configuration, which might be my fault (sorry): you need a trailing slash, so:

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

Also note that you don't need to run manage.py runserver, that's pointless as Apache is serving your app.

这篇关于什么应该是我的Django应用程序的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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