페이지를 새로 고치거나 다시 버튼을 제출하면 양식 다시 제출 오류가 발생합니다. 게시 요청 이후에이를 방지하기 위해 실제 페이지를 리다이렉트하면됩니다. 내가 그렇게 할 때 나는이 mainpge.html에 제출 버튼을 클릭 한 후 페이지 ... 나는 아래의 오류가리디렉션을 통한 Django 고정 확인
오류 : 시작 페이지 /에서 NoReverseMatch/
Reverse for 'testpage' with arguments '()' and keyword arguments '{}' not found.
views.py
from django.shortcuts import render_to_response, redirect
from django.views.decorators.csrf import csrf_exempt
from django.template import Context, RequestContext
@csrf_exempt
def mainpage(request):
return render_to_response('mainpage.html')
@csrf_exempt
def startpage(request):
if request.method == 'POST':
print 'post', request.POST['username']
else:
print 'get', request.GET['username']
variables = RequestContext(request,{'username':request.POST['username'],
'password':request.POST['password']})
#return render_to_response('startpage.html',variables)
return redirect('testpage')
def testpage(request):
variables = {}
return render_to_response('startpage.html',variables)
urls.py
urlpatterns = patterns('',
url(r'^$',mainpage),
url(r'^startpage',startpage),
startpage.html
<html>
<head>
<head>
</head>
<body>
<input type="submit" id="test1" value="mainpage">
This is the StartPage
Entered user name == {{username}}
Entered password == {{password}}
</body>
</html>
mainpage.html
<html>
<head>
</head>
<body>
This is the body
<form method="post" action="/startpage/">{% csrf_token %}
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" value="Sign with password">
</form>
</body>
</html>
고마워요 ... "말씨"는 정확한 실수였습니다 ... – user1050619