Newbie, hierarchical models, url.py problem

1 view
Skip to first unread message

adelaide_mike

unread,
May 30, 2009, 10:18:19 PM5/30/09
to Django users
I have model classes Suburb, Street ,Property and Event.
Each has a name , a foreign key to the model above, and the id
provided by default. In the admin everything is fine.

The template address.html has a search field and returns a startswith
query that generates streets.

Clicking a line in the klist of streets prompts the second line of the
urlpatterns to build a list of propertys.

Clicking a line in propertys returns wha/address/1/3 where 1 is the
id of the street and 3 is the id of the property. But line 1 in
urlpatterns does not work. I have tried everything, as they say, and
have read all the docs I can find, to no avail. I am sure
{{street.id}} is incorrect but I do not know what should replace it.

from django.conf.urls.defaults import *

urlpatterns = patterns('whasite.wha.views',

(r'^address/{{street.id}}/(?P<property_id>\d+)/$', 'select_event'),
(r'^address/(?P<street_id>\d+)/$', 'select_property'),
(r'^address/$', 'select_street'),
(r'^$', 'address'),
)

Have looked at mptt and Pyjamas, both of which seem relevant but I
want to crawl before running.

Any help would be much appreciated. TIA

Mike

Gabriel

unread,
May 30, 2009, 10:46:33 PM5/30/09
to django...@googlegroups.com
adelaide_mike escribió:

> urlpatterns = patterns('whasite.wha.views',
>
> (r'^address/{{street.id}}/(?P<property_id>\d+)/$', 'select_event'),
> (r'^address/(?P<street_id>\d+)/$', 'select_property'),
> (r'^address/$', 'select_street'),
> (r'^$', 'address'),
> )


(r'^address/(?P<street_id>\d+)/(?P<property_id>\d+)/$', 'select_event'),

Url patterns use regular expressions.

- --
Kind regards.

adelaide_mike

unread,
May 30, 2009, 11:24:14 PM5/30/09
to Django users
Thanks Gabriel. I think it would be good if the tutorial included a
three-level hierarchy sowing how to handle the url.py and views.py for
the third layer. Anyway, I now understandone step more.

Thanks and regards
Reply all
Reply to author
Forward
0 new messages