Re: djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Adam Yee

You were right, Django didn't see any URLs in the URLconf file because
I wasn't using the right one.  I had another site also called
'testproject' in a different directory (deleted now).  So I was using
views.py and settings.py in the /web/django directory, but the urls.py
from a totally different one.  It was subtle, and I'm glad I caught it
sooner than later.  All is working fine now with this urls.py when
accessing http://localhost:8080/testproject/time

from django.conf.urls.defaults import *
from testproject.views import current_datetime

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^time/$', current_datetime),
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)

Thanks again.

On Nov 16, 6:31 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-11-16 at 17:41 -0800, Adam Yee wrote:
>
> [...]
>
> Good debugging info snipped.
>
> > When enteringhttp://localhost:8080/testproject/timeI'm reading this
> > in the Apache error log:
>
> > [Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
> > interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
> > [Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
> > (pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
> > testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.
>
> >http://localhost:8080/testproject/timejust brings up 'It worked!'
>
> So the good news is that this means Django is handling the request and
> not exploding, since "it worked" is produced by Django. Which means your
> webserver configuration is correct (or at least very close to correct).
> You're not seeing an error saying something like "Apache doesn't know
> anything about Django".
>
> > Notice how it shows the process as just /testproject and not /
> > testproject/time.
>
> That's correct. The web server hands everything off to what you've
> called "testproject" and Django handles the rest of the stuff.
>
> What's interesting here is that it doesn't redirect to testproject/time/
> (with a trailing slash). Which means Django thinks your URL Conf file is
> empty. Did you just change it and save it without telling Apache to
> reload/restart, so it hasn't picked up the changes, perhaps?
>
> I can't immediately see anything wrong with the setup information you've
> posted, so it's something subtle (or I'm going blind in my old age,
> which is also a candidate).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Malcolm Tredinnick


On Sun, 2008-11-16 at 17:41 -0800, Adam Yee wrote:
[...]

Good debugging info snipped.

> When entering http://localhost:8080/testproject/time I'm reading this
> in the Apache error log:
> 
> [Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
> interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
> [Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
> (pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
> testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.
> 
> http://localhost:8080/testproject/time just brings up 'It worked!'

So the good news is that this means Django is handling the request and
not exploding, since "it worked" is produced by Django. Which means your
webserver configuration is correct (or at least very close to correct).
You're not seeing an error saying something like "Apache doesn't know
anything about Django".

> Notice how it shows the process as just /testproject and not /
> testproject/time.

That's correct. The web server hands everything off to what you've
called "testproject" and Django handles the rest of the stuff.

What's interesting here is that it doesn't redirect to testproject/time/
(with a trailing slash). Which means Django thinks your URL Conf file is
empty. Did you just change it and save it without telling Apache to
reload/restart, so it hasn't picked up the changes, perhaps?

I can't immediately see anything wrong with the setup information you've
posted, so it's something subtle (or I'm going blind in my old age,
which is also a candidate).

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Adam Yee

I'm a new user to Django, hi everyone.

My system:
Windows XP
Python 2.5
Apache 2.2
>>configured for mod_wsgi
MySQL, MySQLdb   #Irrelevant at this point

My issue:
Having trouble getting the through the first example.  Basically, when
directing the browser to '.../time/' I'm still at the 'It worked!'
beginning page.  I haven't been able to bring up the view with
current_datetime.

Some things you might ask to know:
- For Apache:

WSGIScriptAlias /testproject "C:/web/django/apache/django.wsgi"

Order allow,deny
Allow from all


- For my app:
## django.wsgi
import os, sys
sys.path.append('C:/web/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

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

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

## urls.py
from django.conf.urls.defaults import *
from testproject.views import current_datetime

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^testproject/time/$', current_datetime),
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)

When entering http://localhost:8080/testproject/time I'm reading this
in the Apache error log:

[Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
[Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
(pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.

http://localhost:8080/testproject/time just brings up 'It worked!'

Notice how it shows the process as just /testproject and not /
testproject/time.  Is this supposed to be that way?  Is there
something I'm missing in the 'testproject.settings.py' that is
preventing me from seeing the /time URL?  I think everything is setup
correctly.  I've spent a little time looking for an issue related to
this, but couldn't find a post.  Does anybody have any suggestions?
Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---