如果未創建會話,我想重定向到django中的另一個url。 這是我在view.py中的函數代碼。它跳過重定向('/ login')行。我想暫時重定向到網址,以便在登錄後返回到相同的功能。無法重定向到django python中的另一個url
def myfunction(request):
if request.method == "GET":
client_id=request.GET['client_id']
if 'member_id' not in request.session:
redirect('/login')
print "hello"
#print request.session['member_id']
m=client.objects.get(id=client_id)
return HttpResponse("Done")
謝謝!但我面臨着另一個問題。如果會話未創建,則轉到登錄頁面並且用戶登錄並創建會話。但是在這種情況下,我必須返回HttpResponse對象,並且它不會恢復到之前離開的位置 –