Re: Getting URL from within a template
Le 13 mars 2012 à 18:40, Larry Martell a écrit :
> On Tue, Mar 13, 2012 at 11:26 AM, Xavier Ordoquy <xordoquy@linovia.com> wrote:
>> Hi
>>
>> Le 13 mars 2012 à 18:11, Larry.Martell@gmail.com a écrit :
>>
>>> From within a template can I find out the URL that caused the template
>>> to be invoked?
>>
>> You usually should have the request object in your template. See https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path to get the url.
>>
>
> But how do I access that in the template? I tried HttpRequest.path and
> {{ HttpRequest.path }} and neither gives me the URL.
{{ request.path }}
just make sure you have RequestContext if you use render_to_response.
Regards,
Xavier.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home