【发布时间】:2013-01-18 22:03:06
【问题描述】:
我在 html 文件中有一个按钮定义为 ;
<input type="submit" value="Log In" name="login_button" style="width: 109px; "/>
此按钮位于 sample.com 上。用户来并单击此按钮,然后当前网页http://127.0.0.1:8000/sample 更改为在 login.html 中定义的http://127.0.0.1:8000/sample2。出于这个原因,我已经做到了;
def auth(request):
if 'login_button' in request.POST:
// redirect the web page to the sample2.com
return render_to_response('login.html', {} )
我试过redirect("http://127.0.0.1:8000/sample2),但没有成功。我怎样才能转到另一个页面。
在这个函数上定义的其他网页
def message(request):
current_date_T = Template ("<p style=\"text-align: right;\">\
{{Date|truncatewords:\"8\"}}\
</p>")
# --
return HttpResponse(html)
网址文件
urlpatterns = patterns('',
('^sample2/$', message),
('^sample/$', auth),
)
首先打开的页面是示例,其中有一个按钮。单击示例上的按钮后将调用 Sample2。
【问题讨论】:
-
你试过
return声明吗?return redirect("sample2.com) -
@AamirAdnan 你能看看我编辑的问题吗?
-
@AamirAdnan 最后一次编辑,我修正了我的错误,你能帮帮我吗?
-
将您的
urls.py文件内容也发布到您定义了sample2 url的地方 -
@AamirAdnan 看看编辑。