Running my first Django web app

1 view
Skip to first unread message

Gene Ordanza

unread,
Aug 12, 2008, 8:12:08 AM8/12/08
to djangoph
Hi All,

I'm newbie Django user, appreciate any assist and pointers to get my
first app running. I know I'm missing something really basic here,
but just couldn't find it so I'm stuck.

When I try to run my script on the browser (http://server1/mysite/
time), I get the following error messages:

Using the URLconf defined in mysite.urls, Django tried these URL
patterns, in this order:
1. ^time/$
The current URL, /mysite/time/, didn't match any of these.

I have the following script inside "mysite" directory:

views.py:
from django.http import HttpResponse
import datetime

def current_datetime(request):
now = datetime.datetime.now()
html = "<html><body>It is now %s.</body></html>" % now
return HttpResponse(html)

urls.py:
from django.conf.urls.defaults import *
from mysite.views import current_datetime

urlpatterns = patterns ('',
(r'^time/$', current_datetime),
)

Note that I still get the message "It worked!" web page when I comment
out the raw string in the urls.py. I have the following setup.

Django 0.96.2-1
mod_python 3.3.1-5
Apache 2.2.6
Python 2.5.1-15

Here's my httpd.conf setup:

<Location "/mysite">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonPath "['/home/user1/Web/django_projects'] + sys.path"
</Location>

Regards,
--gene

Tim Medina

unread,
Aug 12, 2008, 8:42:27 AM8/12/08
to djan...@googlegroups.com
Hi Gene,

Welcome to the group.

According to the 0.96 docs, (found here: http://www.djangoproject.com/documentation/0.96/modpython/),

Note that Django's URLconfs won't trim the "/mysite/" — they get passed the full URL.

So I guess you'd have to include 'mysite/' in your urls.py.

Also, I recommend that you use the development version. 1.0 is only weeks away anyway. It has a django.root option, which removes the '/mysite/' from the url before it's matched against your URLConf patterns.

Hope this helps.

tim


------


Gene Ordanza

unread,
Aug 12, 2008, 9:30:59 AM8/12/08
to djangoph
Thanks Tim! That did the trick :-)

Awesome that we have Django PH!

Regards,
--gene
Reply all
Reply to author
Forward
0 new messages