List Info

Thread: How to get the urls defined in urls.py




How to get the urls defined in urls.py
user name
2007-12-18 08:10:47
I have my urls.py defined as
urlpatterns = patterns('app.views',
     (r'^foo/$', 'foo'),
     (r'^bar/$', 'bar'),)

Now from a template i need to access these urls. So inside
the
template we can refer them as /foo/, /bar/. However later
when I
change the urls.py, these urls defined in urls.py would
break. What
would be a good way around this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to get the urls defined in urls.py
user name
2007-12-18 08:27:14
On Dec 18, 2007 8:10 AM, shabda <shabda.raajgmail.com> wrote:
> Now from a template i need to access these urls. So
inside the
> template we can refer them as /foo/, /bar/. However
later when I
> change the urls.py, these urls defined in urls.py would
break. What
> would be a good way around this?

You most likely want to look at the documentation on
Django's built-in
template tags.


-- 
"Bureaucrat Conrad, you are technically correct -- the
best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to get the urls defined in urls.py
user name
2007-12-18 08:38:13


On Dec 18, 9:10 am, shabda <shabda.r...gmail.com> wrote:
> I have my urls.py defined as
> urlpatterns = patterns('app.views',
>      (r'^foo/$', 'foo'),
>      (r'^bar/$', 'bar'),)
>
> Now from a template i need to access these urls. So
inside the
> template we can refer them as /foo/, /bar/. However
later when I
> change the urls.py, these urls defined in urls.py would
break. What
> would be a good way around this?

You can name your URL patterns and then use the
"url" templatetag in
your templates. Start here: http://www.djangoproject.com/documen
tation/url_dispatch/#naming-url-patterns
and follow on to the "url" templatetag
description.

-Rajesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )