Yeah, it was just a shorthand to let you understand my problem, it wasn't my actual url definition :)
I was considering the option /country/italy/city/milan/job/engineer/, it wasn't that bat, but i'm risking very long urls if 4-5 parameters are set... On Aug 10, 12:18 pm, Reinout van Rees <rein...@vanrees.org> wrote: > On 10-08-11 11:20, samuele.mattiuzzo wrote: > > > > > url(/<country>/, search_view), > > url(/<city>/, search_view), > > url(/<country>/<city>/, search_view) > > > as you can see, case 1 and case 2 are a trouble: country and city are > > both strings, how's the url supposed to know if a link pointed to one > > url or another? Should i use named views in templating? What's the > > best way i can use them in my case? > > You could make it more explicit: > > url(/country/<country>/, search_view), > url(/city/<city>/, search_view), > url(/country/<country>/<city>/, search_view) > > So prefix all country urls with 'country/' and cities likewise. > > You could, if you like the "/italy/rome" style of urls more, also make > an exception just for cities (but *do* place that exception at the top): > > url(/city/<city>/, search_view), > url(/<country>/, search_view), > url(/<country>/<city>/, search_view) > > So only cities are prefixed with "city/" to distinguish them. > > And you'd better use named variables, so > > /(?P<country>.*)/ > > instead of > > /<country>/ > > (unless you meant that already in your shorthand form, of course). > > The view function then can have keyword arguments: > > def search_view(request, country=None, city=None) > > Reinout > > -- > Reinout van Rees http://reinout.vanrees.org/ > rein...@vanrees.org http://www.nelen-schuurmans.nl/ > "If you're not sure what to do, make something. -- Paul Graham" -- 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.