How to alter the URI in django?
http://packages.python.org/django_simple_feedback/ref/request-response.html tells that the absolute URI is built using the server variables available in this request. So, How can I alter the URI using HttpRequest.build_absolute_uri.
My situation is:
/foo/bar/2/ is the url having corresponding view load_view(request)开发者_运维知识库 Before rendering the template I want to alter the URI by attaching the new absolute URI in the request. So, that My templte renders on the URL /foo/.
You can use django.shortcuts.redirect to redirect to a different location:
def load_view(request):
return redirect('/foo/')
You will still need a corresponding view setup for that url, of course, as this will cause the user's browser to redirect to /foo/. If you want to change the url without refreshing the page, you can do this with HTML5 now:
window.history.pushState('','foo','/foo/');
加载中,请稍侯......
精彩评论