即時通訊沒有得到確切..實際上在httpresponse重定向它什麼也沒有顯示。 實際上http://127.0.0.1:8000/login/在顯示我的登錄頁面 現在我想正確登錄它將重定向到我的索引頁面。 不確切的方式。django頁面重定向成功登錄
def login(request):
template = "../templates/admin/login.html"
data = {
}
user = auth.authenticate(username='aa', password='bb')
if user is not None and user.is_active:
template = "../templates/admin/index.html"
auth.login(request, user)
return HttpResponseRedirect("/login/index/")
return render_to_response(template, data,
context_instance = RequestContext(request))
thanx提前。
http://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.login – 2011-03-29 13:17:56
看起來是對的,我(假定壓痕是在你的版本是正確的)。那會拋出一個python錯誤,無論如何重定向到'/ login/index /',或者重定向成功。你說它正在返回一個空白頁面? – 2011-03-29 13:28:06
實際上,當我寫http://127.0.0.1:8000/login/它會自動重定向到索引頁面,而不顯示登錄頁面 – gurr 2011-03-29 13:39:27