リダイレクト(HttpResponseRedirect)
http://localhost/ で実行していたとして。
これは http://www.google.com/ にリダイレクトされる。
# -*- coding: utf-8 -*- from django.http import HttpResponseRedirect def index(request): return HttpResponseRedirect("http://www.google.com/")
これは http://localhost/section/3/ へリダイレクトされる。
# -*- coding: utf-8 -*- from django.http import HttpResponseRedirect def index(request): return HttpResponseRedirect("/section/3/")
ちなみに http://localhost/section/ で実行していたとして。
これは http://localhost/section/3 へリダイレクトされる。
# -*- coding: utf-8 -*- from django.http import HttpResponseRedirect def index(request): return HttpResponseRedirect("./3")