I am creating a 404.html page in django which will be called when i raise "Http404"
I dont know if 404.html will be passed a "RequestContext" object but can I generate the requested url path without using request variable
I tried "request.path" and "request.get_full_path" but they dont work for me.
Any help would be appreciated.
The 404 template will be rendered with a request context (unlike the 500 server error template).
Make sure that the django.core.context_processors.request context processor is in your TEMPLATE_CONTEXT_PROCESSORS setting. Note that it is not included by default.
Once you've done that, the request methods that you mention like get_full_path should work.
来源:https://stackoverflow.com/questions/10037200/django-get-url-path-without-using-request-path