Redirection

Created on Oct. 17, 2012, 2:01 p.m. by Hevok & updated by Hevok on May 2, 2013, 5:26 p.m.

URL [https://docs.djangoproject.com/en/dev/ref/request-response//django.http.HttpResponseRedirect]." style="color: #CC0000">To redirect to a different page, return a HttpResponseRedirect with the URL [https://docs.djangoproject.com/en/dev/ref/request-response/ django.http.HttpResponseRedirect]. URL to go to from a view name, or a view function identifier, utilize the reverse function [https://docs.djangoproject.com/en/dev/topics/http/urls//reverse]." style="color: #CC0000">In order to generate the URL to go to from a view name, or a view function identifier, utilize the reverse function [https://docs.djangoproject.com/en/dev/topics/http/urls/ reverse]. If additional arguments along with this redirect have to be passed, they need to be encode into the query string. This can be accomplished with the QueryDict class [https://docs.djangoproject.com/en/dev/ref/request-response/ querydict-objects]: ::
data = QueryDict('', mutable=True)
data['information'] = 'need to be passed'
query_str = data.urlencode()
return HttpResponseRedirect('%s?%s' % (url, query_str))
How_To_Redirect_a_Web_Page.png

Tags: coding, django, redirect
Categories: Tutorial
Parent: Web Framework

Update entry (Admin) | See changes

Comment on This Data Unit