Adrian Holovaty wrote:
On 12/30/05, Michael Hipp <[EMAIL PROTECTED]> wrote:

But what about the "root" of the website, how do you specify a view for just
"mysite.com"?


To target the root, use '^$' as the regular expression, like so:

urlpatterns = patterns('',
    (r'^$', 'path.to.my_view'),
)

Does this answer your question?

Yes. But I still seem to be off somewhere...

From http://www.djangoproject.com/documentation/tutorial3/#write-your-first-view
there is:
--------------
from django.utils.httpwrappers import HttpResponse

def index(request):
    return HttpResponse("Hello, world. You're at the poll index.")

This is the simplest view possible. Go to "/polls/" in your browser, and you should see your text.
--------------

I don't know how to reconcile this with what James Bennett and limodou wrote about using render_to_response() instead of HttpResponse() as none of the examples in the docs use render_to_response() as their return value from the view method. So the advice seems contradictory to the docs.

The tutorial seems to be saying that anything returned from a view by way of the HttpResponse() call will be sent directly to the screen. And at another place is shows the url pattern to trap the correct url:
  (r'^polls/$', 'myproject.apps.polls.views.index')
Which seems a simple process of
  urlpattern -> view -> template -> screen

But I can't see in the tutorial example what is put in the template that will receive this "Hello, world..." output.

Thanks,
Michael

Reply via email to