Dear list,

I am wodering whether my implementation is incorrect or whether there is
a typo in the textbook. My question is how I can make sense of these
instructions: "The regular expression to match about/ is r'^about/'".

I was following the "Tango with Django" book.

In the exercises of chapter 3 I am asked to

"""
Now map the view ['about', which we just created] to /rango/about/. For
this step, you’ll only need to edit the urls.py of the rango application.
"""

Later, the author gives some hints, specifically:


"""
The regular expression to match about/ is r'^about/'
"""

Now, there was no way to do this. I finally managed to get

http://127.0.0.1:8000/rango/    and
http://127.0.0.1:8000/rango/about/

running satisfactorily (my code is below), but I was not even sure this
was intended. The author possibly wanted to create

http://127.0.0.1:8000/about/    instead of
http://127.0.0.1:8000/rango/about/

Thanks for clarifying this issue for me!

Cheers,

David




Here is my project/urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'justnow.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    # url(r'^admin/', include(admin.site.urls)),
    url(r'^rango/', include('rango.urls')),  # ADD THIS NEW TUPLE!
    url(r'^about/', include('rango.urls')),  # ADD THIS NEW TUPLE!
)



The app urls.py:

from django.conf.urls import patterns, include, url
from rango import views

urlpatterns = patterns('',
        url(r'^$', views.index, name='Rangos index'),
        url(r'about', views.about, name='About page'),
        )

The app views.py:

from django.http import HttpResponse

def index(request):
    return HttpResponse("Rango says hello. <a
href='/rango/about/'>About</a>")

def about(request):
    return HttpResponse("Here is the about page. <a
href='/rango/'>Index</a>")







david@ubuntu:~/[...]/django_project$ tree
.
├── manage.py
├── notes.txt
├── rango
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   ├── urls.py
│   ├── urls.pyc
│   ├── views.py
│   └── views.pyc
└── tango_with_django_project
    ├── __init__.py
    ├── __init__.pyc
    ├── settings.py
    ├── settings.pyc
    ├── urls.py
    ├── urls.pyc
    ├── wsgi.py
    └── wsgi.pyc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5323A289.9000503%40gmx.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to