如何在python中将页面移动到另一个页面

时间:2018-09-17 04:43:49

标签: python python-3.x

我是python网络开发的新手,目前还不使用python中的django等网络框架。现在,是否有类似PHP(例如header("Location: page.target.php"))的方法将页面用python移动到另一个?

1 个答案:

答案 0 :(得分:2)

对于Django 1.3 +

from django.views.generic import RedirectView

urlpatterns = patterns('',
    (r'^one/$', RedirectView.as_view(url='/another/')),
)

对于早期版本,它是: 从django.views.generic.simple导入redirect_to

urlpatterns = patterns('',
    (r'^one/$', redirect_to, {'url': '/another/'}),
)