views:

168

answers:

1

In Google App Engine, is there a tag or other mechanism to get the URL of the current page in a template or is it necessary to pass the url as a variable to the template from the python code?

+2  A: 

It depends how you are populating the templates. If you are using them outside of Django, then you have to populate them with the URL yourself. If you are using them in Django with the default configuration, you would have to populate them with the URL yourself. An alternative that would avoid you having to populate them yourself is to configure the DJANGO.CORE.CONTEXT_PROCESSORS.REQUEST context processor as described on this page and then access the appropriate part of the request object directly (e.g. request.path).

John
thanks, John. I am using the webapp framework, so I guess I have to provide the url as a variable to the template. Correct?
shanyu
Correct. Django templates don't provide this sort of functionality.
Nick Johnson
Yes, you'll have to provide it yourself.
John