On 1/24/07, vfoley <[EMAIL PROTECTED]> wrote:
>
>
> Hello,
>
> one thing that bugs me about URL patterns is that you can specify a
> prefix only for the view functions to call, not for the URLs to match.
> A quick example
>
> web request:
> http://localhost/project/view/1/
>
> urls.py:
> urlpatterns = patterns('', (r'^view/(?P<id>\d+)/$',
> 'myproject.myapp.views.view'),)
>
> The client will get a 404, because 'project/view/1/' isn't matched.
> Now, I could add project to all my regular expressions, but that seems
> like a whole lot of repetition.  Instead, could we have another
> parameter for patterns() that would trim this part off the passed URL?
> Example:
>
> urls.py:
> urlpatterns = patterns('', prefix_url='project/',
> (r'^view/(?P<id>\d+)/$', 'myproject.myapp.views.view'),)


You can do that by using the include function:

(r'^project/', include('project.app.my_urls')),

Then just place my_urls.py in your project directory. You can name it
anything you want.

Robert


And the previous URL would now work.  If this is something that could
> be useful and that is not currently being worked on, I could try my
> hand at modifying the relevant functions and classes.  Due to the risk
> of breaking older applications, this could be another function.
>
> Vincent
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to