Hi Gerard, Views and not found by the template loader but the the PYTONPATH.. For "project.myapp.views.customer_edit", it finds a project package in your PYTHONPATH and follow the path up to "customer_edit" function. Just using "customer_edit" is a shortcut for the same thing. "customer_edit" is actually concatenated to the base path you gave as 1st argument in the "patterns" function.
The url(..., name="customer_edit") tags your view path with a UNIQUE name which will be used to find back the view. To enforce uniqueness, it is recommended to use "myapp_customer_edit" or use namespace introduced in 1.1. Hope this is getting clearer. Regards, David On Sat, Oct 17, 2009 at 3:08 PM, Gerard <lijss...@gp-net.nl> wrote: > > Hi David, > > Thanx for the feedback. The keyword in your sentence below would be *only* i > assume. Meaning if not named explicitly, there's no way to get the reverse > lookup to work (with the brief notation)? > > Still makes me wonder where the template loader gets it's information from > to be able to find the full path "project.myapp.views.customer_edit" > > I was wondering about this because of my straight forward urlconf in regards > to DRY. Snippet: > > (r'^product/(?P<product_id>\d+)$', 'product_detail', name='product_detail'), > (r'^product/add/(?P<order_id>\d+)$', 'product_add', name='product_add'), > (r'^product/(?P<product_id>\d+)/edit$', 'product_edit', name='product_edit'), > (r'^product/(?P<product_id>\d+)/delete$', 'product_delete', > name='product_delete'), > > Last two parms are equal for all entries. > > Nevertheless thanks. > > Regards, > > Gerard. > > David Paccoud wrote: >> Hi, >> >> You can use {% url customer_edit customer.id %} only if customer_edit >> is declared as the name of view in urls.py. >> See http://docs.djangoproject.com/en/1.1/topics/http/urls/#id2 for more >> details. >> >> David >> >> >> On Sat, Oct 17, 2009 at 11:10 AM, Gerard <lijss...@gp-net.nl> wrote: >>> Hi All, >>> >>> I've been trying to figure out why this works: >>> >>> {% url project.myapp.views.customer_edit customer.id %} >>> >>> And this does not: >>> >>> {% url customer_edit customer.id %} >>> >>> I could go for url() in my patterns and decouple view and pattern name, but >>> is it not possible to tell the template loader (?) where to look for views? >>> >>> Feels like it just needs an import statement on the right place. >>> >>> NB: I tried passing views in patterns as strings and methods. >>> >>> Please advice. >>> >>> Kind regards, >>> >>> Gerard. >>> >>> -- >>> self.url = www.gerardjp.com >>> >> >> > > > > -- > self.url = www.gerardjp.com > > > > --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---