プロジェクトビルダーにDjango1.4を使用しています
http://xxx.xx.xx:8000/index.htmlのようなリクエストを受け取った場合、どうすれば/ home /にリダイレクトできますか?
プロジェクトビルダーにDjango1.4を使用しています
http://xxx.xx.xx:8000/index.htmlのようなリクエストを受け取った場合、どうすれば/ home /にリダイレクトできますか?
すべての /index.html リクエストを /home/ にリダイレクトしますgeneric.simple.redirect_to
from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
(r'^index.html$', redirect_to, {'url': '/home/'}),
(r'^/home/$', 'myapp.views.my_home_view'),
)
urlconfにURLを追加する必要があります
urlpatterns = patterns('',
...
(r'^index\.html$', 'myapp.views.my_home_view'),
...
)
編集
別のオプションは、django.contrib.redirects
アプリを利用し、からindex.html
にリダイレクトする管理者を介してエントリを追加することhome/
です。これはより速く、より構成可能です
の使用redirect_to
方法generic.simple
:
django.views.generic.simple import redirect_to から
urlpatterns = patterns('',
(r'^home/$', 'yourapp.views.home', name='home'),
(r'^index.html$', redirect_to, {'url': '/home/'}),
)