getting current page URL in a Django Template

9 views
Skip to first unread message

NealWalters

unread,
Aug 6, 2009, 4:33:20 PM8/6/09
to Django users
Is there a keyword that will automatically put the URL of the current
page in the Django form?
Or do I have to do that in code and pass it to the form as a normal
user variable?

Here's what I'm trying to accomplish. I have a feedback form on a base
template. When the user clicks the feedback button, it will post to /
submitFeedback. One of my database fields is the URL, so I know which
screen the users was commenting on.

Thanks,
Neal Walters

Daniel Roseman

unread,
Aug 6, 2009, 4:45:34 PM8/6/09
to Django users
If you use RequestContext with the request context_processor, your
template context will always include the request object - from where
you can get request.path which is the current URL. See
http://docs.djangoproject.com/en/dev/ref/templates/api/#id1
http://docs.djangoproject.com/en/dev/ref/request-response/
--
DR.
Reply all
Reply to author
Forward
0 new messages