On 06/14/06 05:45, damacy wrote:
> hi, there.
> 
> is there any built-in function which retrieves the current url in a
> django template?
> 
> for instance, if my current url is
> 
> http://www.lalala.com/hoho?index=0
> 
> and i'd like to get the exactly same url as above within a template
> (including hoho?index=0).
> 
> i can get the current directory which is http://www.lalala.com/ using a
> full stop (i.e. .) unix command, but it does not inlude hoho?index=0.
> 
> sorry if it's got nothing to do with django.
> 
> thanks.
> 

In your settings.py add:

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS += (
     'django.core.context_processors.request',
)

That gives you access to the request object in your templates so you can 
use:

{{ request.get_full_path }}

which in your example would be:

/hoho?index=0

The available props and methods of the request object can be found here [1].

[1] http://www.djangoproject.com/documentation/request_response/

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to